<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<title>API: datatable   DataTable.js  (YUI Library)</title>
	<link rel="stylesheet" type="text/css" href="assets/api.css">
</head>

<body id="yahoo-com">
<div id="doc3" class="yui-t2">

	<div id="hd">
        <h1>Yahoo! UI Library</h1>
        <h3>DataTable Widget&nbsp; <span class="subtitle">2.2.0</span></h3>
        <p>
        <a href="./index.html">Yahoo! UI Library</a> 
            &gt; <a href="./module_datatable.html">datatable</a>
                
                 &gt; DataTable.js (source view) 
            </p>
	</div>

	<div id="bd">
		<div id="yui-main">
			<div class="yui-b">

                    <div id="srcout">
<div class="highlight" ><pre><span class="c">/**</span>
<span class="c"> * The DataTable widget provides a progressively enhanced DHTML control for</span>
<span class="c"> * displaying tabular data across A-grade browsers.</span>
<span class="c"> *</span>
<span class="c"> * @module datatable</span>
<span class="c"> * @requires yahoo, dom, event, datasource</span>
<span class="c"> * @optional dragdrop</span>
<span class="c"> * @title DataTable Widget</span>
<span class="c"> * @beta</span>
<span class="c"> */</span>

<span class="c">/****************************************************************************/</span>
<span class="c">/****************************************************************************/</span>
<span class="c">/****************************************************************************/</span>

<span class="c">/**</span>
<span class="c"> * DataTable class for the YUI DataTable widget.</span>
<span class="c"> *</span>
<span class="c"> * @class DataTable</span>
<span class="c"> * @uses YAHOO.util.EventProvider</span>
<span class="c"> * @constructor</span>
<span class="c"> * @param elContainer {HTMLElement} Container element for the TABLE.</span>
<span class="c"> * @param oColumnSet {YAHOO.widget.ColumnSet} ColumnSet instance.</span>
<span class="c"> * @param oDataSource {YAHOO.util.DataSource} DataSource instance.</span>
<span class="c"> * @param oConfigs {object} (optional) Object literal of configuration values.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">elContainer</span><span class="o">,</span><span class="nx">oColumnSet</span><span class="o">,</span><span class="nx">oDataSource</span><span class="o">,</span><span class="nx">oConfigs</span><span class="o">)</span> <span class="o">{</span>
    <span class="c">// Internal vars</span>
<span class="c"></span>    <span class="k">var</span> <span class="nx">i</span><span class="o">;</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">_nIndex</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">_nCount</span><span class="o">;</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">_sName</span> <span class="o">=</span> <span class="s2">&quot;instance&quot;</span> <span class="o">+</span> <span class="k">this</span><span class="o">.</span><span class="nx">_nIndex</span><span class="o">;</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">id</span> <span class="o">=</span> <span class="s2">&quot;yui-dt&quot;</span><span class="o">+</span><span class="k">this</span><span class="o">.</span><span class="nx">_nIndex</span><span class="o">;</span>

    <span class="c">// Validate configs</span>
<span class="c"></span>    <span class="k">if</span><span class="o">(</span><span class="k">typeof</span> <span class="nx">oConfigs</span> <span class="o">==</span> <span class="s2">&quot;object&quot;</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">sConfig</span> <span class="k">in</span> <span class="nx">oConfigs</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">this</span><span class="o">[</span><span class="nx">sConfig</span><span class="o">]</span> <span class="o">=</span> <span class="nx">oConfigs</span><span class="o">[</span><span class="nx">sConfig</span><span class="o">];</span>
        <span class="o">}</span>
    <span class="o">}</span>

    <span class="c">// Validate DataSource</span>
<span class="c"></span>    <span class="k">if</span><span class="o">(</span><span class="nx">oDataSource</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">oDataSource</span> <span class="k">instanceof</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">DataSource</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">dataSource</span> <span class="o">=</span> <span class="nx">oDataSource</span><span class="o">;</span>
        <span class="o">}</span>
        <span class="k">else</span> <span class="o">{</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Invalid DataSource&quot;</span><span class="o">,</span> <span class="s2">&quot;warn&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
        <span class="o">}</span>
    <span class="o">}</span>

    <span class="c">// Validate ColumnSet</span>
<span class="c"></span>    <span class="k">if</span><span class="o">(</span><span class="nx">oColumnSet</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">oColumnSet</span> <span class="k">instanceof</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">ColumnSet</span><span class="o">))</span> <span class="o">{</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">_oColumnSet</span> <span class="o">=</span> <span class="nx">oColumnSet</span><span class="o">;</span>
    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Could not instantiate DataTable due to an invalid ColumnSet&quot;</span><span class="o">,</span> <span class="s2">&quot;error&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
        <span class="k">return</span><span class="o">;</span>
    <span class="o">}</span>
    
    <span class="c">// Create RecordSet</span>
<span class="c"></span>    <span class="k">this</span><span class="o">.</span><span class="nx">_oRecordSet</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">RecordSet</span><span class="o">();</span>

    <span class="c">// Validate HTML Element</span>
<span class="c"></span>    <span class="nx">elContainer</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="nx">elContainer</span><span class="o">);</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">elContainer</span> <span class="o">&amp;&amp;</span> <span class="nx">elContainer</span><span class="o">.</span><span class="nx">tagName</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">elContainer</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">()</span> <span class="o">==</span> <span class="s2">&quot;div&quot;</span><span class="o">))</span> <span class="o">{</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">_elContainer</span> <span class="o">=</span> <span class="nx">elContainer</span><span class="o">;</span>
        <span class="c">// Peek in container child nodes to see if TABLE already exists</span>
<span class="c"></span>        <span class="k">var</span> <span class="nx">elTable</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">elContainer</span><span class="o">.</span><span class="nx">hasChildNodes</span><span class="o">())</span> <span class="o">{</span>
            <span class="k">var</span> <span class="nx">children</span> <span class="o">=</span> <span class="nx">elContainer</span><span class="o">.</span><span class="nx">childNodes</span><span class="o">;</span>
            <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">children</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
                <span class="k">if</span><span class="o">(</span><span class="nx">children</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">tagName</span> <span class="o">&amp;&amp;</span> <span class="nx">children</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">()</span> <span class="o">==</span> <span class="s2">&quot;table&quot;</span><span class="o">)</span> <span class="o">{</span>
                    <span class="nx">elTable</span> <span class="o">=</span> <span class="nx">children</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>
                    <span class="k">break</span><span class="o">;</span>
                <span class="o">}</span>
            <span class="o">}</span>
        <span class="o">}</span>

        <span class="c">// Progressively enhance an existing table from markup...</span>
<span class="c"></span>        <span class="c">// while using the markup as the source of data</span>
<span class="c"></span>        <span class="k">if</span><span class="o">(</span><span class="nx">elTable</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="k">this</span><span class="o">.</span><span class="nx">dataSource</span><span class="o">)</span> <span class="o">{</span>
            <span class="c">// Fill RecordSet with data parsed out of table</span>
<span class="c"></span>            <span class="k">var</span> <span class="nx">aRecords</span> <span class="o">=</span> <span class="o">[];</span>

            <span class="c">// Iterate through each TBODY</span>
<span class="c"></span>            <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">elTable</span><span class="o">.</span><span class="nx">tBodies</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
                <span class="k">var</span> <span class="nx">elBody</span> <span class="o">=</span> <span class="nx">elTable</span><span class="o">.</span><span class="nx">tBodies</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>

                <span class="c">// Iterate through each TR</span>
<span class="c"></span>                <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">j</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">j</span><span class="o">&lt;</span><span class="nx">elBody</span><span class="o">.</span><span class="nx">rows</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">j</span><span class="o">++)</span> <span class="o">{</span>
                    <span class="k">var</span> <span class="nx">elRow</span> <span class="o">=</span> <span class="nx">elBody</span><span class="o">.</span><span class="nx">rows</span><span class="o">[</span><span class="nx">j</span><span class="o">];</span>
                    <span class="k">var</span> <span class="nx">oRecord</span> <span class="o">=</span> <span class="o">{};</span>

                    <span class="c">// Iterate through each TD</span>
<span class="c"></span>                    <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">k</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">k</span><span class="o">&lt;</span><span class="nx">elRow</span><span class="o">.</span><span class="nx">cells</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">k</span><span class="o">++)</span> <span class="o">{</span>

                        <span class="c">//var elCell = elRow.cells[l];</span>
<span class="c"></span>                        <span class="c">//elCell.id = this.id+&quot;-bdrow&quot;+k+&quot;-cell&quot;+l;</span>
<span class="c"></span>                        <span class="c">//TODO: can we parse a column with null key?</span>
<span class="c"></span>                        <span class="nx">oRecord</span><span class="o">[</span><span class="nx">oColumnSet</span><span class="o">.</span><span class="nx">keys</span><span class="o">[</span><span class="nx">k</span><span class="o">].</span><span class="nx">key</span><span class="o">]</span> <span class="o">=</span> <span class="nx">oColumnSet</span><span class="o">.</span><span class="nx">keys</span><span class="o">[</span><span class="nx">k</span><span class="o">].</span><span class="nx">parse</span><span class="o">(</span><span class="nx">elRow</span><span class="o">.</span><span class="nx">cells</span><span class="o">[</span><span class="nx">k</span><span class="o">].</span><span class="nx">innerHTML</span><span class="o">);</span>
                    <span class="o">}</span>
                    <span class="nx">aRecords</span><span class="o">.</span><span class="nx">push</span><span class="o">(</span><span class="nx">oRecord</span><span class="o">);</span>
                <span class="o">}</span>
            <span class="o">}</span>
            
            <span class="k">this</span><span class="o">.</span><span class="nx">_initTable</span><span class="o">();</span>
            
            <span class="k">var</span> <span class="nx">ok</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">doBeforeLoadData</span><span class="o">(</span><span class="nx">aRecords</span><span class="o">);</span>
            <span class="k">if</span><span class="o">(</span><span class="nx">ok</span><span class="o">)</span> <span class="o">{</span>
                <span class="k">this</span><span class="o">.</span><span class="nx">_oRecordSet</span><span class="o">.</span><span class="nx">addRecords</span><span class="o">(</span><span class="nx">aRecords</span><span class="o">);</span>
                <span class="k">this</span><span class="o">.</span><span class="nx">paginateRows</span><span class="o">();</span>
            <span class="o">}</span>
        <span class="o">}</span>
        <span class="c">// Create markup from scratch using the provided DataSource</span>
<span class="c"></span>        <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">dataSource</span><span class="o">)</span> <span class="o">{</span>
                <span class="k">this</span><span class="o">.</span><span class="nx">_initTable</span><span class="o">();</span>
                <span class="c">// Send out for data in an asynchronous request</span>
<span class="c"></span>                <span class="nx">oDataSource</span><span class="o">.</span><span class="nx">sendRequest</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">initialRequest</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">onDataReturnPaginateRows</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
        <span class="o">}</span>
        <span class="c">// Else there is no data</span>
<span class="c"></span>        <span class="k">else</span> <span class="o">{</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">_initTable</span><span class="o">();</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">showEmptyMessage</span><span class="o">();</span>
        <span class="o">}</span>
    <span class="o">}</span>
    <span class="c">// Container element not found in document</span>
<span class="c"></span>    <span class="k">else</span> <span class="o">{</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Could not instantiate DataTable due to an invalid container element&quot;</span><span class="o">,</span> <span class="s2">&quot;error&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
        <span class="k">return</span><span class="o">;</span>
    <span class="o">}</span>

    <span class="c">// Set up sort</span>
<span class="c"></span>    <span class="k">this</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span><span class="s2">&quot;headCellClickEvent&quot;</span><span class="o">,</span><span class="k">this</span><span class="o">.</span><span class="nx">onEventSortColumn</span><span class="o">);</span>

    <span class="c">// Set up context menu</span>
<span class="c"></span>    <span class="c">//TODO: does trigger have to exist? can trigger be TBODY rather than rows?</span>
<span class="c"></span>    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">contextMenu</span> <span class="o">&amp;&amp;</span> <span class="k">this</span><span class="o">.</span><span class="nx">contextMenuOptions</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">contextMenu</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">ContextMenu</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">id</span><span class="o">+</span><span class="s2">&quot;-cm&quot;</span><span class="o">,</span> <span class="o">{</span> <span class="nx">trigger</span><span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elBody</span><span class="o">.</span><span class="nx">rows</span> <span class="o">}</span> <span class="o">);</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">contextMenu</span><span class="o">.</span><span class="nx">addItem</span><span class="o">(</span><span class="s2">&quot;delete item&quot;</span><span class="o">);</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">contextMenu</span><span class="o">.</span><span class="nx">render</span><span class="o">(</span><span class="nb">document</span><span class="o">.</span><span class="nx">body</span><span class="o">);</span>
    <span class="o">}</span>

    <span class="c">// Set up event model</span>
<span class="c"></span>    <span class="nx">elTable</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elTable</span><span class="o">;</span>
    <span class="c">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c"></span>    <span class="c">//</span>
<span class="c"></span>    <span class="c">// DOM Events</span>
<span class="c"></span>    <span class="c">//</span>
<span class="c"></span>    <span class="c">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c"></span>    <span class="c">//YAHOO.util.Event.addListener(this._elContainer, &quot;focus&quot;, this._onFocus, this);</span>
<span class="c"></span>    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">addListener</span><span class="o">(</span><span class="nx">elTable</span><span class="o">,</span> <span class="s2">&quot;click&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onClick</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">addListener</span><span class="o">(</span><span class="nx">elTable</span><span class="o">,</span> <span class="s2">&quot;dblclick&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onDoubleclick</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">addListener</span><span class="o">(</span><span class="nx">elTable</span><span class="o">,</span> <span class="s2">&quot;mouseout&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onMouseout</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">addListener</span><span class="o">(</span><span class="nx">elTable</span><span class="o">,</span> <span class="s2">&quot;mouseover&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onMouseover</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">addListener</span><span class="o">(</span><span class="nx">elTable</span><span class="o">,</span> <span class="s2">&quot;mousedown&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onMousedown</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
    <span class="c">//YAHOO.util.Event.addListener(elTable, &quot;mouseup&quot;, this._onMouseup, this);</span>
<span class="c"></span>    <span class="c">//YAHOO.util.Event.addListener(elTable, &quot;mousemove&quot;, this._onMousemove, this);</span>
<span class="c"></span>    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">addListener</span><span class="o">(</span><span class="nx">elTable</span><span class="o">,</span> <span class="s2">&quot;keydown&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onKeydown</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">addListener</span><span class="o">(</span><span class="nx">elTable</span><span class="o">,</span> <span class="s2">&quot;keypress&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onKeypress</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">addListener</span><span class="o">(</span><span class="nb">document</span><span class="o">,</span> <span class="s2">&quot;keyup&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onDocumentKeyup</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">addListener</span><span class="o">(</span><span class="nx">elTable</span><span class="o">,</span> <span class="s2">&quot;keyup&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onKeyup</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>
    <span class="c">//YAHOO.util.Event.addListener(elTable, &quot;focus&quot;, this._onFocus, this);</span>
<span class="c"></span>    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">addListener</span><span class="o">(</span><span class="nx">elTable</span><span class="o">,</span> <span class="s2">&quot;blur&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onBlur</span><span class="o">,</span> <span class="k">this</span><span class="o">);</span>

    <span class="c">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c"></span>    <span class="c">//</span>
<span class="c"></span>    <span class="c">// Custom Events</span>
<span class="c"></span>    <span class="c">//</span>
<span class="c"></span>    <span class="c">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c"></span>
    <span class="c">/**</span>
<span class="c">     * Fired when a mouseover occurs on a TD element.</span>
<span class="c">     *</span>
<span class="c">     * @event cellMouseoverEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The TD element.</span>
<span class="c">     */</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">createEvent</span><span class="o">(</span><span class="s2">&quot;cellMouseoverEvent&quot;</span><span class="o">);</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a mouseout occurs on a TD element.</span>
<span class="c">     *</span>
<span class="c">     * @event cellMouseoutEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The TD element.</span>
<span class="c">     */</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">createEvent</span><span class="o">(</span><span class="s2">&quot;cellMouseoutEvent&quot;</span><span class="o">);</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a TH cell element is mouseover.</span>
<span class="c">     *</span>
<span class="c">     * @event headCellMouseoverEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The TH element.</span>
<span class="c">     *</span>
<span class="c">     */</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">createEvent</span><span class="o">(</span><span class="s2">&quot;headCellMouseoverEvent&quot;</span><span class="o">);</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a TH cell element is mouseout.</span>
<span class="c">     *</span>
<span class="c">     * @event headCellMouseoutEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The TH element.</span>
<span class="c">     *</span>
<span class="c">     */</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">createEvent</span><span class="o">(</span><span class="s2">&quot;headCellMouseoutEvent&quot;</span><span class="o">);</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a TABLE element is mouseover.</span>
<span class="c">     *</span>
<span class="c">     * @event tableMouseoverEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The TABLE element.</span>
<span class="c">     *</span>
<span class="c">     */</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">createEvent</span><span class="o">(</span><span class="s2">&quot;tableMouseoverEvent&quot;</span><span class="o">);</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a TABLE element is mouseout.</span>
<span class="c">     *</span>
<span class="c">     * @event tableMouseoutEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The TABLE element.</span>
<span class="c">     *</span>
<span class="c">     */</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">createEvent</span><span class="o">(</span><span class="s2">&quot;tableMouseoutEvent&quot;</span><span class="o">);</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a mousedown occurs on a TD element.</span>
<span class="c">     *</span>
<span class="c">     * @event cellMousedownEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The TD element.</span>
<span class="c">     */</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">createEvent</span><span class="o">(</span><span class="s2">&quot;cellMousedownEvent&quot;</span><span class="o">);</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a TH cell element is mousedown.</span>
<span class="c">     *</span>
<span class="c">     * @event headCellMousedownEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The TH element.</span>
<span class="c">     */</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">createEvent</span><span class="o">(</span><span class="s2">&quot;headCellMousedownEvent&quot;</span><span class="o">);</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a TABLE element is mousedown.</span>
<span class="c">     *</span>
<span class="c">     * @event tableMousedownEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The TABLE element.</span>
<span class="c">     *</span>
<span class="c">     */</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">createEvent</span><span class="o">(</span><span class="s2">&quot;tableMousedownEvent&quot;</span><span class="o">);</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a CHECKBOX element is clicked.</span>
<span class="c">     *</span>
<span class="c">     * @event checkboxClickEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The CHECKBOX element.</span>
<span class="c">     */</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">checkboxClickEvent</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">createEvent</span><span class="o">(</span><span class="s2">&quot;checkboxClickEvent&quot;</span><span class="o">);</span>
    <span class="c">//this.checkboxClickEvent.subscribeEvent.subscribe(this._registerEvent,{type:&quot;checkboxClickEvent&quot;},this);</span>
<span class="c"></span>
    <span class="c">/**</span>
<span class="c">     * Fired when a RADIO element is clicked.</span>
<span class="c">     *</span>
<span class="c">     * @event radioClickEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The RADIO element.</span>
<span class="c">     */</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">createEvent</span><span class="o">(</span><span class="s2">&quot;radioClickEvent&quot;</span><span class="o">);</span>
    
    <span class="c">/**</span>
<span class="c">     * Fired when a TD element is clicked.</span>
<span class="c">     *</span>
<span class="c">     * @event cellClickEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The TD element.</span>
<span class="c">     */</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">createEvent</span><span class="o">(</span><span class="s2">&quot;cellClickEvent&quot;</span><span class="o">);</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a TH cell element is clicked.</span>
<span class="c">     *</span>
<span class="c">     * @event headCellClickEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The TH element.</span>
<span class="c">     */</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">createEvent</span><span class="o">(</span><span class="s2">&quot;headCellClickEvent&quot;</span><span class="o">);</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a TABLE element is clicked.</span>
<span class="c">     *</span>
<span class="c">     * @event tableClickEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The TABLE element.</span>
<span class="c">     *</span>
<span class="c">     */</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">createEvent</span><span class="o">(</span><span class="s2">&quot;tableClickEvent&quot;</span><span class="o">);</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a TD element is doubleclicked.</span>
<span class="c">     *</span>
<span class="c">     * @event cellDoubleclickEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The TD element.</span>
<span class="c">     */</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">createEvent</span><span class="o">(</span><span class="s2">&quot;cellDoubleclickEvent&quot;</span><span class="o">);</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a TH cell element is doubleclicked.</span>
<span class="c">     *</span>
<span class="c">     * @event headCellDoubleclickEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The TH element.</span>
<span class="c">     */</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">createEvent</span><span class="o">(</span><span class="s2">&quot;headCellDoubleclickEvent&quot;</span><span class="o">);</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a TABLE element is doubleclicked.</span>
<span class="c">     *</span>
<span class="c">     * @event tableDoubleclickEvent</span>
<span class="c">     * @param oArgs.event {HTMLEvent} The event object.</span>
<span class="c">     * @param oArgs.target {HTMLElement} The TABLE element.</span>
<span class="c">     *</span>
<span class="c">     */</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">createEvent</span><span class="o">(</span><span class="s2">&quot;tableDoubleclickEvent&quot;</span><span class="o">);</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a column is sorted.</span>
<span class="c">     *</span>
<span class="c">     * @event columnSortEvent</span>
<span class="c">     * @param oArgs.column {YAHOO.widget.Column} The Column instance.</span>
<span class="c">     * @param oArgs.dir {String} Sort direction &quot;asc&quot; or &quot;desc&quot;.</span>
<span class="c">     */</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">createEvent</span><span class="o">(</span><span class="s2">&quot;columnSortEvent&quot;</span><span class="o">);</span>

    <span class="c">/**</span>
<span class="c">     * Fired when an editor is activated.</span>
<span class="c">     *</span>
<span class="c">     * @event editorShowEvent</span>
<span class="c">     * @param oArgs.target {HTMLElement} The TD element.</span>
<span class="c">     * @param oArgs.column {YAHOO.widget.Column} The Column instance.</span>
<span class="c">     */</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">createEvent</span><span class="o">(</span><span class="s2">&quot;editorShowEvent&quot;</span><span class="o">);</span>


    <span class="c">/**</span>
<span class="c">     * Fired when a cell is edited.</span>
<span class="c">     *</span>
<span class="c">     * @event cellEditEvent</span>
<span class="c">     * @param oArgs.target {HTMLElement} The TD element.</span>
<span class="c">     * @param oArgs.newData {Object} New data value.</span>
<span class="c">     * @param oArgs.oldData {Object} Old data value.</span>
<span class="c">     */</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">createEvent</span><span class="o">(</span><span class="s2">&quot;cellEditEvent&quot;</span><span class="o">);</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a column is resized.</span>
<span class="c">     *</span>
<span class="c">     * @event columnResizeEvent</span>
<span class="c">     * @param oArgs.target {HTMLElement} The TH element.</span>
<span class="c">     */</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">createEvent</span><span class="o">(</span><span class="s2">&quot;columnResizeEvent&quot;</span><span class="o">);</span>

    <span class="c">/**</span>
<span class="c">     * Fired when DataTable instance is first initialized.</span>
<span class="c">     *</span>
<span class="c">     * @event tableInitEvent</span>
<span class="c">     */</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">createEvent</span><span class="o">(</span><span class="s2">&quot;tableInitEvent&quot;</span><span class="o">);</span>

    <span class="c">/**</span>
<span class="c">     * Fired when DataTable instance is focused.</span>
<span class="c">     *</span>
<span class="c">     * @event tableFocusEvent</span>
<span class="c">     */</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">createEvent</span><span class="o">(</span><span class="s2">&quot;tableFocusEvent&quot;</span><span class="o">);</span>

    <span class="c">/**</span>
<span class="c">     * Fired when data is returned from DataSource.</span>
<span class="c">     *</span>
<span class="c">     * @event dataReturnEvent</span>
<span class="c">     * @param oArgs.request {String} Original request.</span>
<span class="c">     * @param oArgs.response {Object} Response object.</span>
<span class="c">     */</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">createEvent</span><span class="o">(</span><span class="s2">&quot;dataReturnEvent&quot;</span><span class="o">);</span>

    <span class="c">/**</span>
<span class="c">     * Fired when DataTable is paginated.</span>
<span class="c">     *</span>
<span class="c">     * @event paginateEvent</span>
<span class="c">     */</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">createEvent</span><span class="o">(</span><span class="s2">&quot;paginateEvent&quot;</span><span class="o">);</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a TD element is formatted.</span>
<span class="c">     *</span>
<span class="c">     * @event cellFormatEvent</span>
<span class="c">     * @param oArgs.el {HTMLElement} Reference to the TD element.</span>
<span class="c">     */</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">createEvent</span><span class="o">(</span><span class="s2">&quot;cellFormatEvent&quot;</span><span class="o">);</span>

    <span class="c">/**</span>
<span class="c">     * Fired when an element is selected.</span>
<span class="c">     *</span>
<span class="c">     * @event selectEvent</span>
<span class="c">     * @param oArgs.els {Array} An array of the selected element(s).</span>
<span class="c">     */</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">createEvent</span><span class="o">(</span><span class="s2">&quot;selectEvent&quot;</span><span class="o">);</span>

    <span class="c">/**</span>
<span class="c">     * Fired when an element is unselected.</span>
<span class="c">     *</span>
<span class="c">     * @event unselectEvent</span>
<span class="c">     * @param oArgs.els {Array} An array of the unselected element(s).</span>
<span class="c">     */</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">createEvent</span><span class="o">(</span><span class="s2">&quot;unselectEvent&quot;</span><span class="o">);</span>

    <span class="c">/**</span>
<span class="c">     * Fired when an element is highlighted.</span>
<span class="c">     *</span>
<span class="c">     * @event highlightEvent</span>
<span class="c">     * @param oArgs.els {Array} An array of the highlighted element(s).</span>
<span class="c">     */</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">createEvent</span><span class="o">(</span><span class="s2">&quot;highlightEvent&quot;</span><span class="o">);</span>

    <span class="c">/**</span>
<span class="c">     * Fired when an element is unhighlighted.</span>
<span class="c">     *</span>
<span class="c">     * @event unhighlightEvent</span>
<span class="c">     * @param oArgs.els {Array} An array of the unhighlighted element(s).</span>
<span class="c">     */</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">createEvent</span><span class="o">(</span><span class="s2">&quot;unhighlightEvent&quot;</span><span class="o">);</span>
    
    <span class="c">/**</span>
<span class="c">     * Fired when one or more TR elements are deleted.</span>
<span class="c">     *</span>
<span class="c">     * @event rowDeleteEvent</span>
<span class="c">     * @param oArgs.rowIndexes {Array} The indexes of the deleted rows.</span>
<span class="c">     */</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">createEvent</span><span class="o">(</span><span class="s2">&quot;rowDeleteEvent&quot;</span><span class="o">);</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span><span class="s2">&quot;rowDeleteEvent&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onRowDelete</span><span class="o">);</span>
    
    <span class="c">/**</span>
<span class="c">     * Fired when one or more TR elements are appended.</span>
<span class="c">     *</span>
<span class="c">     * @event rowAppendEvent</span>
<span class="c">     * @param oArgs.rowIds {Array} The IDs of the appended rows.</span>
<span class="c">     */</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">createEvent</span><span class="o">(</span><span class="s2">&quot;rowAppendEvent&quot;</span><span class="o">);</span>

    <span class="c">/**</span>
<span class="c">     * Fired when a Record is updated in the RecordSet.</span>
<span class="c">     *</span>
<span class="c">     * @event recordSetUpdateEvent</span>
<span class="c">     * @param oArgs.record {YAHOO.widget.Record} The Record instance.</span>
<span class="c">     * @param oArgs.key {String} The Record key.</span>
<span class="c">     * @param oArgs.newData {Object} New data.</span>
<span class="c">     * @param oArgs.oldData {Object} New data.</span>
<span class="c">     */</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">createEvent</span><span class="o">(</span><span class="s2">&quot;recordSetUpdateEvent&quot;</span><span class="o">);</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">_oRecordSet</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">(</span><span class="s2">&quot;recordUpdateEvent&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_onRecordUpdate</span><span class="o">,</span> <span class="k">this</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
    
    
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">_nCount</span><span class="o">++;</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;DataTable initialized&quot;</span><span class="o">,</span> <span class="s2">&quot;info&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;tableInitEvent&quot;</span><span class="o">);</span>
<span class="o">};</span>

<span class="k">if</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">EventProvider</span><span class="o">)</span> <span class="o">{</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">augment</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">EventProvider</span><span class="o">);</span>
<span class="o">}</span>
<span class="k">else</span> <span class="o">{</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Missing dependency: YAHOO.util.EventProvider&quot;</span><span class="o">,</span><span class="s2">&quot;error&quot;</span><span class="o">,</span><span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
<span class="o">}</span>

<span class="c">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c">//</span>
<span class="c">// Public constants</span>
<span class="c">//</span>
<span class="c">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c"></span>
<span class="c">/**</span>
<span class="c"> * Class name assigned to TBODY element that holds data rows.</span>
<span class="c"> *</span>
<span class="c"> * @property CLASS_BODY</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-body&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_BODY</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-body&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to container element within THEAD.</span>
<span class="c"> *</span>
<span class="c"> * @property CLASS_HEADCONTAINER</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_HEADCONTAINER</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-headcontainer&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to resizer handle element within THEAD.</span>
<span class="c"> *</span>
<span class="c"> * @property CLASS_HEADRESIZER</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-headresizer&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_HEADRESIZER</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-headresizer&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to text displayed within THEAD.</span>
<span class="c"> *</span>
<span class="c"> * @property CLASS_HEADTEXT</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-headtext&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_HEADTEXT</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-headtext&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to even TR elements.</span>
<span class="c"> *</span>
<span class="c"> * @property CLASS_EVEN</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-even</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_EVEN</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-even&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to odd TR elements.</span>
<span class="c"> *</span>
<span class="c"> * @property CLASS_ODD</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-odd&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_ODD</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-odd&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to empty elements.</span>
<span class="c"> *</span>
<span class="c"> * @property CLASS_EMPTY</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-empty&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_EMPTY</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-empty&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to loading message.</span>
<span class="c"> *</span>
<span class="c"> * @property CLASS_LOADING</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-loading&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_LOADING</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-loading&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to selected elements.</span>
<span class="c"> *</span>
<span class="c"> * @property CLASS_SELECTED</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-selected&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_SELECTED</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-selected&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to highlighted element.</span>
<span class="c"> *</span>
<span class="c"> * @property CLASS_HIGHLIGHT</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-highlight&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_HIGHLIGHT</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-highlight&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to certain elements of a scrollable DataTable.</span>
<span class="c"> *</span>
<span class="c"> * @property CLASS_SCROLLABLE</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-scrollable&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_SCROLLABLE</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-scrollable&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to column headers of sortable Columns.</span>
<span class="c"> *</span>
<span class="c"> * @property CLASS_SORTABLE</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-sortable&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_SORTABLE</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-sortable&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to column headers when sorted in ascending order.</span>
<span class="c"> *</span>
<span class="c"> * @property CLASS_SORTEDBYASC</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-sortedbyasc&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_SORTEDBYASC</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-sortedbyasc&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to column headers when sorted in descending order.</span>
<span class="c"> *</span>
<span class="c"> * @property CLASS_SORTEDBYDESC</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-sortedbydesc&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_SORTEDBYDESC</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-sortedbydesc&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to the pagination link &quot;&amp;lt;&amp;lt;&quot;.</span>
<span class="c"> *</span>
<span class="c"> * @property CLASS_FIRSTLINK</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-firstlink&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_FIRSTLINK</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-firstlink&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to the pagination link &quot;&amp;lt;&amp;lt;&quot; when it is disabled.</span>
<span class="c"> *</span>
<span class="c"> * @property CLASS_FIRSTPAGE</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-firstpage&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_FIRSTPAGE</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-firstpage&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to the pagination link &quot;&amp;gt;&amp;gt;&quot;.</span>
<span class="c"> *</span>
<span class="c"> * @property CLASS_LASTLINK</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-lastlink&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_LASTLINK</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-lastlink&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to the pagination link &quot;&amp;gt;&amp;gt;&quot; when it is disabled.</span>
<span class="c"> *</span>
<span class="c"> * @property CLASS_LASTPAGE</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-lastpage&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_LASTPAGE</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-lastpage&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to the pagination link &quot;&amp;lt;&quot;.</span>
<span class="c"> *</span>
<span class="c"> * @property CLASS_PREVLINK</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-prevlink&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_PREVLINK</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-prevlink&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to the pagination link &quot;&amp;lt;&quot; when it is disabled.</span>
<span class="c"> *</span>
<span class="c"> * @property CLASS_PREVPAGE</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-prevpage&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_PREVPAGE</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-prevpage&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to the pagination link &quot;&amp;gt;&quot;.</span>
<span class="c"> *</span>
<span class="c"> * @property CLASS_NEXTLINK</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-nextlink&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_NEXTLINK</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-nextlink&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to the pagination link &quot;&amp;gt;&quot; when it is disabled.</span>
<span class="c"> *</span>
<span class="c"> * @property CLASS_NEXTPAGE</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-nextpage&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_NEXTPAGE</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-nextpage&quot;</span><span class="o">;</span>


<span class="c">/**</span>
<span class="c"> * Class name assigned to pagination links to specific page numbers.</span>
<span class="c"> *</span>
<span class="c"> * @property CLASS_PAGELINK</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-pagelink&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_PAGELINK</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-pagelink&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to pagination links for specific page numbers that are disabled.</span>
<span class="c"> *</span>
<span class="c"> * @property CLASS_CURRENTPAGE</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-currentpage&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_CURRENTPAGE</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-currentpage&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to the pagination SELECT element.</span>
<span class="c"> *</span>
<span class="c"> * @property CLASS_PAGESELECT</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-pageselect&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_PAGESELECT</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-pageselect&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to the pagination links container element.</span>
<span class="c"> *</span>
<span class="c"> * @property CLASS_PAGELINKS</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-pagelinks&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_PAGELINKS</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-pagelinks&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to editable TD elements.</span>
<span class="c"> *</span>
<span class="c"> * @property CLASS_EDITABLE</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-editable&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_EDITABLE</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-editable&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to TD elements of type &quot;checkbox&quot;.</span>
<span class="c"> *</span>
<span class="c"> * @property CLASS_CHECKBOX</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-checkbox&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_CHECKBOX</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-checkbox&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to TD elements of type &quot;currency&quot;.</span>
<span class="c"> *</span>
<span class="c"> * @property CLASS_CURRENCY</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-currency&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_CURRENCY</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-currency&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to TD elements of type &quot;date&quot;.</span>
<span class="c"> *</span>
<span class="c"> * @property CLASS_DATE</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-date&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_DATE</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-date&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to TD elements of type &quot;email&quot;.</span>
<span class="c"> *</span>
<span class="c"> * @property CLASS_EMAIL</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-email&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_EMAIL</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-email&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to TD elements of type &quot;link&quot;.</span>
<span class="c"> *</span>
<span class="c"> * @property CLASS_LINK</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-link&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_LINK</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-link&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to TD elements of type &quot;number&quot;.</span>
<span class="c"> *</span>
<span class="c"> * @property CLASS_NUMBER</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-number&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_NUMBER</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-number&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Class name assigned to TD elements of type &quot;string&quot;.</span>
<span class="c"> *</span>
<span class="c"> * @property CLASS_STRING</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;yui-dt-string&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_STRING</span> <span class="o">=</span> <span class="s2">&quot;yui-dt-string&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Message to display if DataTable has no data.</span>
<span class="c"> *</span>
<span class="c"> * @property MSG_EMPTY</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;No records found.&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">MSG_EMPTY</span> <span class="o">=</span> <span class="s2">&quot;No records found.&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Message to display while DataTable is loading data.</span>
<span class="c"> *</span>
<span class="c"> * @property MSG_LOADING</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> * @final</span>
<span class="c"> * @default &quot;Loading data...&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">MSG_LOADING</span> <span class="o">=</span> <span class="s2">&quot;Loading data...&quot;</span><span class="o">;</span>

<span class="c">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c">//</span>
<span class="c">// Private member variables</span>
<span class="c">//</span>
<span class="c">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c"></span>
<span class="c">/**</span>
<span class="c"> * Internal class variable to index multiple DataTable instances.</span>
<span class="c"> *</span>
<span class="c"> * @property _nCount</span>
<span class="c"> * @type Number</span>
<span class="c"> * @private</span>
<span class="c"> * @static</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">_nCount</span> <span class="o">=</span> <span class="m">0</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Instance index.</span>
<span class="c"> *</span>
<span class="c"> * @property _nIndex</span>
<span class="c"> * @type Number</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_nIndex</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Unique instance name.</span>
<span class="c"> *</span>
<span class="c"> * @property _sName</span>
<span class="c"> * @type String</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_sName</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>

<span class="c">//TODO: convert these to public members</span>
<span class="c"></span>
<span class="c">/**</span>
<span class="c"> * Container element reference. Is null unless the TABLE is built from scratch into the</span>
<span class="c"> * provided container.</span>
<span class="c"> *</span>
<span class="c"> * @property _elContainer</span>
<span class="c"> * @type HTMLElement</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_elContainer</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * TABLE element reference.</span>
<span class="c"> *</span>
<span class="c"> * @property _elTable</span>
<span class="c"> * @type HTMLElement</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_elTable</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * TBODY element reference.</span>
<span class="c"> *</span>
<span class="c"> * @property _elBody</span>
<span class="c"> * @type HTMLElement</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_elBody</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * ColumnSet instance.</span>
<span class="c"> *</span>
<span class="c"> * @property _oColumnSet</span>
<span class="c"> * @type YAHOO.widget.ColumnSet</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_oColumnSet</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * RecordSet instance.</span>
<span class="c"> *</span>
<span class="c"> * @property _oRecordSet</span>
<span class="c"> * @type YAHOO.widget.RecordSet</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_oRecordSet</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Array of Records that are in the selected state.</span>
<span class="c"> *</span>
<span class="c"> * @property _aSelectedRecords</span>
<span class="c"> * @type YAHOO.widget.Record[]</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_aSelectedRecords</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Internal variable to track whether widget has focus.</span>
<span class="c"> *</span>
<span class="c"> * @property _bFocused</span>
<span class="c"> * @type Boolean</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_bFocused</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Total number of pages, calculated on the fly.</span>
<span class="c"> *</span>
<span class="c"> * @property _totalPages</span>
<span class="c"> * @type Number</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_totalPages</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>


<span class="c">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c">//</span>
<span class="c">// Private methods</span>
<span class="c">//</span>
<span class="c">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c"></span>
<span class="c">/**</span>
<span class="c"> * Creates HTML markup for TABLE, THEAD, TBODY.</span>
<span class="c"> *</span>
<span class="c"> * @method _initTable</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_initTable</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="c">// Clear the container</span>
<span class="c"></span>    <span class="k">this</span><span class="o">.</span><span class="nx">_elContainer</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span><span class="o">;</span>

    <span class="c">// Set up scrolling</span>
<span class="c"></span>    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">scrollable</span><span class="o">)</span> <span class="o">{</span>
        <span class="c">//TODO: conf height</span>
<span class="c"></span>        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_elContainer</span><span class="o">,</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_SCROLLABLE</span><span class="o">);</span>
    <span class="o">}</span>

    <span class="c">// Create TABLE</span>
<span class="c"></span>    <span class="k">this</span><span class="o">.</span><span class="nx">_elTable</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elContainer</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;table&quot;</span><span class="o">));</span>
    <span class="k">var</span> <span class="nx">elTable</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elTable</span><span class="o">;</span>
    <span class="nx">elTable</span><span class="o">.</span><span class="nx">tabIndex</span> <span class="o">=</span> <span class="m">0</span><span class="o">;</span>

    <span class="c">// Create SUMMARY, if applicable</span>
<span class="c"></span>    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">summary</span><span class="o">)</span> <span class="o">{</span>
        <span class="nx">elTable</span><span class="o">.</span><span class="nx">summary</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">summary</span><span class="o">;</span>
    <span class="o">}</span>

    <span class="c">// Create CAPTION, if applicable</span>
<span class="c"></span>    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">caption</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">_elCaption</span> <span class="o">=</span> <span class="nx">elTable</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;caption&quot;</span><span class="o">));</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">_elCaption</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">caption</span><span class="o">;</span>
    <span class="o">}</span>

    <span class="c">// Create THEAD</span>
<span class="c"></span>    <span class="k">this</span><span class="o">.</span><span class="nx">_initHead</span><span class="o">(</span><span class="nx">elTable</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oColumnSet</span><span class="o">);</span>


    <span class="c">// Create TBODY for messages</span>
<span class="c"></span>    <span class="k">var</span> <span class="nx">elMsgBody</span> <span class="o">=</span> <span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;tbody&quot;</span><span class="o">);</span>
    <span class="nx">elMsgBody</span><span class="o">.</span><span class="nx">tabIndex</span> <span class="o">=</span> <span class="o">-</span><span class="m">1</span><span class="o">;</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">_elMsgRow</span> <span class="o">=</span> <span class="nx">elMsgBody</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;tr&quot;</span><span class="o">));</span>
    <span class="k">var</span> <span class="nx">elMsgRow</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elMsgRow</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">elMsgCell</span> <span class="o">=</span> <span class="nx">elMsgRow</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;td&quot;</span><span class="o">));</span>
    <span class="nx">elMsgCell</span><span class="o">.</span><span class="nx">colSpan</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oColumnSet</span><span class="o">.</span><span class="nx">keys</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">_elMsgCell</span> <span class="o">=</span> <span class="nx">elMsgCell</span><span class="o">;</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">_elMsgBody</span> <span class="o">=</span> <span class="nx">elTable</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nx">elMsgBody</span><span class="o">);</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">showLoadingMessage</span><span class="o">();</span>

    <span class="c">// Create TBODY for data</span>
<span class="c"></span>    <span class="k">this</span><span class="o">.</span><span class="nx">_elBody</span> <span class="o">=</span> <span class="nx">elTable</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;tbody&quot;</span><span class="o">));</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">_elBody</span><span class="o">.</span><span class="nx">tabIndex</span> <span class="o">=</span> <span class="o">-</span><span class="m">1</span><span class="o">;</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_elBody</span><span class="o">,</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_BODY</span><span class="o">);</span>
    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">scrollable</span><span class="o">)</span> <span class="o">{</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_elBody</span><span class="o">,</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_SCROLLABLE</span><span class="o">);</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Populates THEAD element with TH cells as defined by ColumnSet.</span>
<span class="c"> *</span>
<span class="c"> * @method _initHead</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_initHead</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">i</span><span class="o">,</span><span class="nx">oColumn</span><span class="o">;</span>
    
    <span class="c">// Create THEAD</span>
<span class="c"></span>    <span class="k">var</span> <span class="nx">elHead</span> <span class="o">=</span> <span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;thead&quot;</span><span class="o">);</span>
    <span class="nx">elHead</span><span class="o">.</span><span class="nx">tabIndex</span> <span class="o">=</span> <span class="o">-</span><span class="m">1</span><span class="o">;</span>

    <span class="c">// Iterate through each row of Column headers...</span>
<span class="c"></span>    <span class="k">var</span> <span class="nx">colTree</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oColumnSet</span><span class="o">.</span><span class="nx">tree</span><span class="o">;</span>
    <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">colTree</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">elHeadRow</span> <span class="o">=</span> <span class="nx">elHead</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;tr&quot;</span><span class="o">));</span>
        <span class="nx">elHeadRow</span><span class="o">.</span><span class="nx">id</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">id</span><span class="o">+</span><span class="s2">&quot;-hdrow&quot;</span><span class="o">+</span><span class="nx">i</span><span class="o">;</span>

        <span class="c">// ...and create THEAD cells</span>
<span class="c"></span>        <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">j</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">j</span><span class="o">&lt;</span><span class="nx">colTree</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">length</span><span class="o">;</span> <span class="nx">j</span><span class="o">++)</span> <span class="o">{</span>
            <span class="nx">oColumn</span> <span class="o">=</span> <span class="nx">colTree</span><span class="o">[</span><span class="nx">i</span><span class="o">][</span><span class="nx">j</span><span class="o">];</span>
            <span class="k">var</span> <span class="nx">elHeadCell</span> <span class="o">=</span> <span class="nx">elHeadRow</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;th&quot;</span><span class="o">));</span>
            <span class="nx">elHeadCell</span><span class="o">.</span><span class="nx">id</span> <span class="o">=</span> <span class="nx">oColumn</span><span class="o">.</span><span class="nx">getId</span><span class="o">();</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">_initHeadCell</span><span class="o">(</span><span class="nx">elHeadCell</span><span class="o">,</span><span class="nx">oColumn</span><span class="o">,</span><span class="nx">i</span><span class="o">,</span><span class="nx">j</span><span class="o">);</span>
        <span class="o">}</span>
    <span class="o">}</span>

    <span class="k">this</span><span class="o">.</span><span class="nx">_elHead</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elTable</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nx">elHead</span><span class="o">);</span>
    
    <span class="c">// Add Resizer only after DOM has been updated...</span>
<span class="c"></span>    <span class="c">// ...and skip the last column</span>
<span class="c"></span>    <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="k">this</span><span class="o">.</span><span class="nx">_oColumnSet</span><span class="o">.</span><span class="nx">keys</span><span class="o">.</span><span class="nx">length</span><span class="o">-</span><span class="m">1</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
        <span class="nx">oColumn</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oColumnSet</span><span class="o">.</span><span class="nx">keys</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">resizeable</span> <span class="o">&amp;&amp;</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">DD</span><span class="o">)</span> <span class="o">{</span>
            <span class="c">//TODO: deal with fixed width tables</span>
<span class="c"></span>            <span class="c">//TODO: no more oColumn.isLast</span>
<span class="c"></span>            <span class="k">if</span><span class="o">(!</span><span class="k">this</span><span class="o">.</span><span class="nx">fixedWidth</span> <span class="o">||</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">fixedwidth</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">isLast</span><span class="o">))</span> <span class="o">{</span>
                <span class="c">// TODO: better way to get elHeadContainer</span>
<span class="c"></span>                <span class="k">var</span> <span class="nx">elHeadContainer</span> <span class="o">=</span> <span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">getElementsByClassName</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_HEADCONTAINER</span><span class="o">,</span><span class="s2">&quot;div&quot;</span><span class="o">,</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">getId</span><span class="o">())))[</span><span class="m">0</span><span class="o">];</span>
                <span class="k">var</span> <span class="nx">elHeadResizer</span> <span class="o">=</span> <span class="nx">elHeadContainer</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;span&quot;</span><span class="o">));</span>
                <span class="nx">elHeadResizer</span><span class="o">.</span><span class="nx">id</span> <span class="o">=</span> <span class="nx">oColumn</span><span class="o">.</span><span class="nx">getId</span><span class="o">()</span> <span class="o">+</span> <span class="s2">&quot;-resizer&quot;</span><span class="o">;</span>
                <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">elHeadResizer</span><span class="o">,</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_HEADRESIZER</span><span class="o">);</span>
                <span class="nx">oColumn</span><span class="o">.</span><span class="nx">ddResizer</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">WidthResizer</span><span class="o">(</span>
                        <span class="k">this</span><span class="o">,</span> <span class="nx">oColumn</span><span class="o">.</span><span class="nx">getId</span><span class="o">(),</span> <span class="nx">elHeadResizer</span><span class="o">.</span><span class="nx">id</span><span class="o">,</span> <span class="nx">elHeadResizer</span><span class="o">.</span><span class="nx">id</span><span class="o">);</span>
                <span class="k">var</span> <span class="nx">cancelClick</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">e</span><span class="o">)</span> <span class="o">{</span>
                    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">stopPropagation</span><span class="o">(</span><span class="nx">e</span><span class="o">);</span>
                <span class="o">};</span>
                <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">addListener</span><span class="o">(</span><span class="nx">elHeadResizer</span><span class="o">,</span><span class="s2">&quot;click&quot;</span><span class="o">,</span><span class="nx">cancelClick</span><span class="o">);</span>
            <span class="o">}</span>
            <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">fixedWidth</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">elHeadContainer</span><span class="o">.</span><span class="nx">style</span><span class="o">.</span><span class="nx">overflow</span> <span class="o">=</span> <span class="s2">&quot;hidden&quot;</span><span class="o">;</span>
                <span class="nx">elHeadContent</span><span class="o">.</span><span class="nx">style</span><span class="o">.</span><span class="nx">overflow</span> <span class="o">=</span> <span class="s2">&quot;hidden&quot;</span><span class="o">;</span>
            <span class="o">}</span>
        <span class="o">}</span>
    <span class="o">}</span>

    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;THEAD with &quot;</span> <span class="o">+</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oColumnSet</span><span class="o">.</span><span class="nx">keys</span><span class="o">.</span><span class="nx">length</span> <span class="o">+</span> <span class="s2">&quot; columns created&quot;</span><span class="o">,</span><span class="s2">&quot;info&quot;</span><span class="o">,</span><span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Populates TH cell as defined by Column.</span>
<span class="c"> *</span>
<span class="c"> * @method _initHeadCell</span>
<span class="c"> * @param elHeadCell {HTMLElement} TH cell element reference.</span>
<span class="c"> * @param oColumn {YAHOO.widget.Column} Column object.</span>
<span class="c"> * @param row {number} Row index.</span>
<span class="c"> * @param col {number} Column index.</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_initHeadCell</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">elHeadCell</span><span class="o">,</span><span class="nx">oColumn</span><span class="o">,</span><span class="nx">row</span><span class="o">,</span><span class="nx">col</span><span class="o">)</span> <span class="o">{</span>
    <span class="c">// Clear out the cell of prior content</span>
<span class="c"></span>    <span class="c">// TODO: purgeListeners and other validation-related things</span>
<span class="c"></span>    <span class="k">var</span> <span class="nx">index</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_nIndex</span><span class="o">;</span>
    <span class="nx">elHeadCell</span><span class="o">.</span><span class="nx">columnIndex</span> <span class="o">=</span> <span class="nx">col</span><span class="o">;</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">abbr</span><span class="o">)</span> <span class="o">{</span>
        <span class="nx">elHeadCell</span><span class="o">.</span><span class="nx">abbr</span> <span class="o">=</span> <span class="nx">oColumn</span><span class="o">.</span><span class="nx">abbr</span><span class="o">;</span>
    <span class="o">}</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">width</span><span class="o">)</span> <span class="o">{</span>
        <span class="nx">elHeadCell</span><span class="o">.</span><span class="nx">style</span><span class="o">.</span><span class="nx">width</span> <span class="o">=</span> <span class="nx">oColumn</span><span class="o">.</span><span class="nx">width</span><span class="o">;</span>
    <span class="o">}</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">className</span><span class="o">)</span> <span class="o">{</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">elHeadCell</span><span class="o">,</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">className</span><span class="o">);</span>
    <span class="o">}</span>
    <span class="c">// Apply CSS for sorted tables</span>
<span class="c"></span>    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">sortedBy</span> <span class="o">&amp;&amp;</span> <span class="k">this</span><span class="o">.</span><span class="nx">sortedBy</span><span class="o">.</span><span class="nx">colKey</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">sortedBy</span><span class="o">.</span><span class="nx">colKey</span> <span class="o">==</span> <span class="nx">oColumn</span><span class="o">.</span><span class="nx">key</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">var</span> <span class="nx">sortClass</span> <span class="o">=</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">sortedBy</span><span class="o">.</span><span class="nx">dir</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">sortedBy</span><span class="o">.</span><span class="nx">dir</span> <span class="o">!=</span> <span class="s2">&quot;asc&quot;</span><span class="o">))</span> <span class="o">?</span>
                    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_SORTEDBYDESC</span> <span class="o">:</span>
                    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_SORTEDBYASC</span><span class="o">;</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">elHeadCell</span><span class="o">,</span><span class="nx">sortClass</span><span class="o">);</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">sortedBy</span><span class="o">.</span><span class="nx">_id</span> <span class="o">=</span> <span class="nx">elHeadCell</span><span class="o">.</span><span class="nx">id</span><span class="o">;</span>
        <span class="o">}</span>
    <span class="o">}</span>

    <span class="nx">elHeadCell</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span><span class="o">;</span>

    <span class="k">var</span> <span class="nx">elHeadContainer</span> <span class="o">=</span> <span class="nx">elHeadCell</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;div&quot;</span><span class="o">));</span>
    <span class="nx">elHeadContainer</span><span class="o">.</span><span class="nx">id</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">id</span><span class="o">+</span><span class="s2">&quot;-hdrow&quot;</span><span class="o">+</span><span class="nx">row</span><span class="o">+</span><span class="s2">&quot;-container&quot;</span><span class="o">+</span><span class="nx">col</span><span class="o">;</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">elHeadContainer</span><span class="o">,</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_HEADCONTAINER</span><span class="o">);</span>
    <span class="k">var</span> <span class="nx">elHeadContent</span> <span class="o">=</span> <span class="nx">elHeadContainer</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;span&quot;</span><span class="o">));</span>
    <span class="nx">elHeadContent</span><span class="o">.</span><span class="nx">id</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">id</span><span class="o">+</span><span class="s2">&quot;-hdrow&quot;</span><span class="o">+</span><span class="nx">row</span><span class="o">+</span><span class="s2">&quot;-text&quot;</span><span class="o">+</span><span class="nx">col</span><span class="o">;</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">elHeadContent</span><span class="o">,</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_HEADTEXT</span><span class="o">);</span>

    <span class="nx">elHeadCell</span><span class="o">.</span><span class="nx">rowSpan</span> <span class="o">=</span> <span class="nx">oColumn</span><span class="o">.</span><span class="nx">getRowSpan</span><span class="o">();</span>
    <span class="nx">elHeadCell</span><span class="o">.</span><span class="nx">colSpan</span> <span class="o">=</span> <span class="nx">oColumn</span><span class="o">.</span><span class="nx">getColSpan</span><span class="o">();</span>

    <span class="k">var</span> <span class="nx">contentText</span> <span class="o">=</span> <span class="nx">oColumn</span><span class="o">.</span><span class="nx">text</span> <span class="o">||</span> <span class="nx">oColumn</span><span class="o">.</span><span class="nx">key</span> <span class="o">||</span> <span class="s2">&quot;&quot;</span><span class="o">;</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">sortable</span><span class="o">)</span> <span class="o">{</span>
        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">elHeadContent</span><span class="o">,</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_SORTABLE</span><span class="o">);</span>
        <span class="c">//TODO: Make hash configurable to be a server link</span>
<span class="c"></span>        <span class="c">//TODO: Make title configurable</span>
<span class="c"></span>        <span class="c">//TODO: Separate contentText from an accessibility link that says</span>
<span class="c"></span>        <span class="c">// Click to sort ascending and push it offscreen</span>
<span class="c"></span>        <span class="nx">elHeadContent</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="s2">&quot;&lt;a href=\&quot;#\&quot; title=\&quot;Click to sort\&quot;&gt;&quot;</span> <span class="o">+</span> <span class="nx">contentText</span> <span class="o">+</span> <span class="s2">&quot;&lt;/a&gt;&quot;</span><span class="o">;</span>
         <span class="c">//elHeadContent.innerHTML = contentText;</span>
<span class="c"></span>
    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>
        <span class="nx">elHeadContent</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="nx">contentText</span><span class="o">;</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Add a new row to table body at position i if given, or to the bottom</span>
<span class="c"> * otherwise. Does not fire any events.</span>
<span class="c"> *</span>
<span class="c"> * @method _addRow</span>
<span class="c"> * @param oRecord {YAHOO.widget.Record} Record instance.</span>
<span class="c"> * @param index {Number} Position at which to add row.</span>
<span class="c"> * @return {String} ID of the added TR element.</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_addRow</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">oRecord</span><span class="o">,</span> <span class="nx">index</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">hideTableMessages</span><span class="o">();</span>

    <span class="c">// Is this an insert or an append?</span>
<span class="c"></span>    <span class="k">var</span> <span class="nx">insert</span> <span class="o">=</span> <span class="o">(</span><span class="nb">isNaN</span><span class="o">(</span><span class="nx">index</span><span class="o">))</span> <span class="o">?</span> <span class="kc">false</span> <span class="o">:</span> <span class="kc">true</span><span class="o">;</span>
    <span class="k">if</span><span class="o">(!</span><span class="nx">insert</span><span class="o">)</span> <span class="o">{</span>
        <span class="nx">index</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elBody</span><span class="o">.</span><span class="nx">rows</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span>
    <span class="o">}</span>

    <span class="k">var</span> <span class="nx">oColumnSet</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oColumnSet</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">oRecordSet</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oRecordSet</span><span class="o">;</span>

    <span class="k">var</span> <span class="nx">elRow</span> <span class="o">=</span> <span class="o">(</span><span class="nx">insert</span> <span class="o">&amp;&amp;</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elBody</span><span class="o">.</span><span class="nx">rows</span><span class="o">[</span><span class="nx">index</span><span class="o">])</span> <span class="o">?</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">_elBody</span><span class="o">.</span><span class="nx">insertBefore</span><span class="o">(</span><span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;tr&quot;</span><span class="o">),</span><span class="k">this</span><span class="o">.</span><span class="nx">_elBody</span><span class="o">.</span><span class="nx">rows</span><span class="o">[</span><span class="nx">index</span><span class="o">])</span> <span class="o">:</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">_elBody</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;tr&quot;</span><span class="o">));</span>
    <span class="k">var</span> <span class="nx">recId</span> <span class="o">=</span> <span class="nx">oRecord</span><span class="o">.</span><span class="nx">id</span><span class="o">;</span>
    <span class="nx">elRow</span><span class="o">.</span><span class="nx">id</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">id</span><span class="o">+</span><span class="s2">&quot;-bdrow&quot;</span><span class="o">+</span><span class="nx">index</span><span class="o">;</span>
    <span class="nx">elRow</span><span class="o">.</span><span class="nx">recordId</span> <span class="o">=</span> <span class="nx">recId</span><span class="o">;</span>

    <span class="c">// Create TBODY cells</span>
<span class="c"></span>    <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">j</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">j</span><span class="o">&lt;</span><span class="nx">oColumnSet</span><span class="o">.</span><span class="nx">keys</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">j</span><span class="o">++)</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">oColumn</span> <span class="o">=</span> <span class="nx">oColumnSet</span><span class="o">.</span><span class="nx">keys</span><span class="o">[</span><span class="nx">j</span><span class="o">];</span>
        <span class="k">var</span> <span class="nx">elCell</span> <span class="o">=</span> <span class="nx">elRow</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;td&quot;</span><span class="o">));</span>
        <span class="nx">elCell</span><span class="o">.</span><span class="nx">id</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">id</span><span class="o">+</span><span class="s2">&quot;-bdrow&quot;</span><span class="o">+</span><span class="nx">index</span><span class="o">+</span><span class="s2">&quot;-cell&quot;</span><span class="o">+</span><span class="nx">j</span><span class="o">;</span>
        <span class="nx">elCell</span><span class="o">.</span><span class="nx">headers</span> <span class="o">=</span> <span class="nx">oColumn</span><span class="o">.</span><span class="nx">id</span><span class="o">;</span>
        <span class="nx">elCell</span><span class="o">.</span><span class="nx">columnIndex</span> <span class="o">=</span> <span class="nx">j</span><span class="o">;</span>
        <span class="nx">elCell</span><span class="o">.</span><span class="nx">headers</span> <span class="o">=</span> <span class="nx">oColumnSet</span><span class="o">.</span><span class="nx">headers</span><span class="o">[</span><span class="nx">j</span><span class="o">];</span>

        <span class="nx">oColumn</span><span class="o">.</span><span class="nx">format</span><span class="o">(</span><span class="nx">elCell</span><span class="o">,</span> <span class="nx">oRecord</span><span class="o">);</span>
        <span class="c">/*p.abx {word-wrap:break-word;}</span>
<span class="c">ought to solve the problem for Safari (the long words will wrap in your</span>
<span class="c">tds, instead of overflowing to the next td.</span>
<span class="c">(this is supported by IE win as well, so hide it if needed).</span>
<span class="c"></span>
<span class="c">One thing, though: it doesn&#39;t work in combination with</span>
<span class="c">&#39;white-space:nowrap&#39;.*/</span>

<span class="c">// need a div wrapper for safari?</span>
<span class="c"></span>        <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">fixedWidth</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">elCell</span><span class="o">.</span><span class="nx">style</span><span class="o">.</span><span class="nx">overflow</span> <span class="o">=</span> <span class="s2">&quot;hidden&quot;</span><span class="o">;</span>
            <span class="c">//elCell.style.width = &quot;20px&quot;;</span>
<span class="c"></span>        <span class="o">}</span>
    <span class="o">}</span>

    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">isEmpty</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_elBody</span><span class="o">.</span><span class="nx">rows</span><span class="o">.</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">))</span> <span class="o">{</span>
        <span class="c">//TODO: hideMessages()</span>
<span class="c"></span>        <span class="c">//this._initRows()</span>
<span class="c"></span>        <span class="c">//this.isEmpty = false;</span>
<span class="c"></span>    <span class="o">}</span>

    <span class="c">// Striping</span>
<span class="c"></span>    <span class="k">if</span><span class="o">(!</span><span class="nx">insert</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">index</span><span class="o">%</span><span class="m">2</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">elRow</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_ODD</span><span class="o">);</span>
        <span class="o">}</span>
        <span class="k">else</span> <span class="o">{</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">elRow</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_EVEN</span><span class="o">);</span>
        <span class="o">}</span>
    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>
        <span class="c">//TODO: pass in a subset for better performance</span>
<span class="c"></span>        <span class="k">this</span><span class="o">.</span><span class="nx">_restripeRows</span><span class="o">();</span>
    <span class="o">}</span>
    
    <span class="k">return</span> <span class="nx">elRow</span><span class="o">.</span><span class="nx">id</span><span class="o">;</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Restripes rows by applying class YAHOO.widget.DataTable.CLASS_EVEN or</span>
<span class="c"> * YAHOO.widget.DataTable.CLASS_ODD.</span>
<span class="c"> *</span>
<span class="c"> * @method _restripeRows</span>
<span class="c"> * @param range {Number} (optional) Range defines a subset of rows to restripe.</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_restripeRows</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">range</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">if</span><span class="o">(!</span><span class="nx">range</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">rows</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elBody</span><span class="o">.</span><span class="nx">rows</span><span class="o">;</span>
        <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">rows</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
            <span class="k">if</span><span class="o">(</span><span class="nx">i</span><span class="o">%</span><span class="m">2</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">removeClass</span><span class="o">(</span><span class="nx">rows</span><span class="o">[</span><span class="nx">i</span><span class="o">],</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_EVEN</span><span class="o">);</span>
                <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">rows</span><span class="o">[</span><span class="nx">i</span><span class="o">],</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_ODD</span><span class="o">);</span>
            <span class="o">}</span>
            <span class="k">else</span> <span class="o">{</span>
                <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">removeClass</span><span class="o">(</span><span class="nx">rows</span><span class="o">[</span><span class="nx">i</span><span class="o">],</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_ODD</span><span class="o">);</span>
                <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">rows</span><span class="o">[</span><span class="nx">i</span><span class="o">],</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_EVEN</span><span class="o">);</span>
            <span class="o">}</span>
        <span class="o">}</span>
    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>
        <span class="c">//TODO: allow restriping of a subset of rows for performance</span>
<span class="c"></span>    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Updates existing row at position i with data from the given Record. Does not</span>
<span class="c"> * fire any events.</span>
<span class="c"> *</span>
<span class="c"> * @method _updateRow</span>
<span class="c"> * @param oRecord {YAHOO.widget.Record} Record instance.</span>
<span class="c"> * @param index {Number} Position at which to update row.</span>
<span class="c"> * @return {String} ID of the updated TR element.</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_updateRow</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">oRecord</span><span class="o">,</span> <span class="nx">index</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">hideTableMessages</span><span class="o">();</span>

    <span class="k">var</span> <span class="nx">elRow</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elBody</span><span class="o">.</span><span class="nx">rows</span><span class="o">[</span><span class="nx">index</span><span class="o">];</span>
    <span class="nx">elRow</span><span class="o">.</span><span class="nx">recordId</span> <span class="o">=</span> <span class="nx">oRecord</span><span class="o">.</span><span class="nx">id</span><span class="o">;</span>

    <span class="k">var</span> <span class="nx">columns</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oColumnSet</span><span class="o">.</span><span class="nx">keys</span><span class="o">;</span>
    <span class="c">// ...Update TBODY cells with new data</span>
<span class="c"></span>    <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">j</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">j</span><span class="o">&lt;</span><span class="nx">columns</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">j</span><span class="o">++)</span> <span class="o">{</span>
        <span class="nx">columns</span><span class="o">[</span><span class="nx">j</span><span class="o">].</span><span class="nx">format</span><span class="o">(</span><span class="nx">elRow</span><span class="o">.</span><span class="nx">cells</span><span class="o">[</span><span class="nx">j</span><span class="o">],</span> <span class="nx">oRecord</span><span class="o">);</span>
    <span class="o">}</span>
    <span class="k">return</span> <span class="nx">elRow</span><span class="o">.</span><span class="nx">id</span><span class="o">;</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Sets elements to selected state. Does not fire any events. Does not affect</span>
<span class="c"> * internal tracker.</span>
<span class="c"> *</span>
<span class="c"> * @method _select</span>
<span class="c"> * @param els {HTMLElement[] | String[]} Array of HTML elements by reference or ID string.</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_select</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">els</span><span class="o">)</span> <span class="o">{</span>
<span class="c">//TODO: put els in an array if it is just one element?</span>
<span class="c"></span>    <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">els</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
        <span class="c">// Set the style</span>
<span class="c"></span>        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="nx">els</span><span class="o">[</span><span class="nx">i</span><span class="o">]),</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_SELECTED</span><span class="o">);</span>
    <span class="o">}</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">_lastSelected</span> <span class="o">=</span> <span class="nx">els</span><span class="o">[</span><span class="nx">els</span><span class="o">.</span><span class="nx">length</span><span class="o">-</span><span class="m">1</span><span class="o">];</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Sets elements to the unselected state. Does not fire any events. Does not</span>
<span class="c"> * affect internal tracker.</span>
<span class="c"> *</span>
<span class="c"> * @method _unselect</span>
<span class="c"> * @param els {HTMLElement[] | String[]} Array of HTML elements by reference or ID string.</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_unselect</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">els</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">els</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
        <span class="c">// Remove the style</span>
<span class="c"></span>        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">removeClass</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="nx">els</span><span class="o">[</span><span class="nx">i</span><span class="o">]),</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_SELECTED</span><span class="o">);</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Unselects all selected rows. Does not fire any events. Does not affect internal</span>
<span class="c"> * tracker.</span>
<span class="c"> *</span>
<span class="c"> * @method _unselectAllRows</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_unselectAllRows</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">selectedRows</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">getElementsByClassName</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_SELECTED</span><span class="o">,</span><span class="s2">&quot;tr&quot;</span><span class="o">,</span><span class="k">this</span><span class="o">.</span><span class="nx">_elBody</span><span class="o">);</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">_unselect</span><span class="o">(</span><span class="nx">selectedRows</span><span class="o">);</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Unselects all selected cells.</span>
<span class="c"> *</span>
<span class="c"> * @method _unselectAllCells</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_unselectAllCells</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">selectedCells</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">getElementsByClassName</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_SELECTED</span><span class="o">,</span><span class="s2">&quot;td&quot;</span><span class="o">,</span><span class="k">this</span><span class="o">.</span><span class="nx">_elBody</span><span class="o">);</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">_unselect</span><span class="o">(</span><span class="nx">selectedCells</span><span class="o">);</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Deletes a given row element as well its corresponding Record in the RecordSet.</span>
<span class="c"> * Does not fire any events.</span>
<span class="c"> *</span>
<span class="c"> * @method _deleteRow</span>
<span class="c"> * @param elRow {element} HTML table row element reference.</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_deleteRow</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">elRow</span><span class="o">)</span> <span class="o">{</span>
<span class="c">//TODO: sniff elRow.rowIndex</span>
<span class="c"></span>    <span class="k">var</span> <span class="nx">allRows</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elBody</span><span class="o">.</span><span class="nx">rows</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">id</span> <span class="o">=</span> <span class="nx">elRow</span><span class="o">.</span><span class="nx">id</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">recordId</span> <span class="o">=</span> <span class="nx">elRow</span><span class="o">.</span><span class="nx">recordId</span><span class="o">;</span>
    <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span> <span class="nx">allRows</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">id</span> <span class="o">==</span> <span class="nx">allRows</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">id</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">_elBody</span><span class="o">.</span><span class="nx">deleteRow</span><span class="o">(</span><span class="nx">i</span><span class="o">);</span>

            <span class="c">// Update the RecordSet</span>
<span class="c"></span>            <span class="k">this</span><span class="o">.</span><span class="nx">_oRecordSet</span><span class="o">.</span><span class="nx">deleteRecord</span><span class="o">(</span><span class="nx">i</span><span class="o">);</span>
            <span class="k">break</span><span class="o">;</span>
        <span class="o">}</span>
    <span class="o">}</span>
    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_elBody</span><span class="o">.</span><span class="nx">rows</span><span class="o">.</span><span class="nx">length</span> <span class="o">===</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">showEmptyMessage</span><span class="o">();</span>
    <span class="o">}</span>
<span class="o">};</span>
<span class="c">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c">//</span>
<span class="c">// Private DOM Event Handlers</span>
<span class="c">//</span>
<span class="c">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c"></span>
<span class="c">/**</span>
<span class="c"> * Handles blur events on the TABLE element.</span>
<span class="c"> *</span>
<span class="c"> * @method _onBlur</span>
<span class="c"> * @param e {HTMLEvent} The blur event.</span>
<span class="c"> * @param oSelf {YAHOO.widget.DataTable} DataTable instance.</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_onBlur</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">e</span><span class="o">,</span> <span class="nx">oSelf</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">_bFocused</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Handles mouseover events on the TABLE element.</span>
<span class="c"> *</span>
<span class="c"> * @method _onMouseover</span>
<span class="c"> * @param e {HTMLEvent} The mouseover event.</span>
<span class="c"> * @param oSelf {YAHOO.widget.DataTable} DataTable instance.</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_onMouseover</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">e</span><span class="o">,</span> <span class="nx">oSelf</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">elTarget</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">getTarget</span><span class="o">(</span><span class="nx">e</span><span class="o">);</span>
        <span class="k">var</span> <span class="nx">elTag</span> <span class="o">=</span> <span class="nx">elTarget</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">();</span>
        <span class="k">var</span> <span class="nx">knownTag</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>

        <span class="k">if</span> <span class="o">(</span><span class="nx">elTag</span> <span class="o">!=</span> <span class="s2">&quot;table&quot;</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">while</span><span class="o">(!</span><span class="nx">knownTag</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">switch</span><span class="o">(</span><span class="nx">elTag</span><span class="o">)</span> <span class="o">{</span>
                    <span class="nx">case</span> <span class="s2">&quot;body&quot;</span><span class="o">:</span>
                        <span class="nx">knownTag</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
                        <span class="k">break</span><span class="o">;</span>
                    <span class="nx">case</span> <span class="s2">&quot;td&quot;</span><span class="o">:</span>
                        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;cellMouseoverEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:</span><span class="nx">elTarget</span><span class="o">,</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
                        <span class="nx">knownTag</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
                        <span class="k">break</span><span class="o">;</span>
                    <span class="nx">case</span> <span class="s2">&quot;th&quot;</span><span class="o">:</span>
                        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;headCellMouseoverEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:</span><span class="nx">elTarget</span><span class="o">,</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
                        <span class="nx">knownTag</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
                        <span class="k">break</span><span class="o">;</span>
                    <span class="nx">default</span><span class="o">:</span>
                        <span class="k">break</span><span class="o">;</span>
                <span class="o">}</span>
                <span class="nx">elTarget</span> <span class="o">=</span> <span class="nx">elTarget</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">;</span>
                <span class="k">if</span><span class="o">(</span><span class="nx">elTarget</span><span class="o">)</span> <span class="o">{</span>
                    <span class="nx">elTag</span> <span class="o">=</span> <span class="nx">elTarget</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">();</span>
                <span class="o">}</span>
                <span class="k">else</span> <span class="o">{</span>
                    <span class="k">break</span><span class="o">;</span>
                <span class="o">}</span>
            <span class="o">}</span>
        <span class="o">}</span>
        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;tableMouseoverEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:</span><span class="nx">elTarget</span><span class="o">,</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Handles mouseout events on the TABLE element.</span>
<span class="c"> *</span>
<span class="c"> * @method _onMouseout</span>
<span class="c"> * @param e {HTMLEvent} The mouseout event.</span>
<span class="c"> * @param oSelf {YAHOO.widget.DataTable} DataTable instance.</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_onMouseout</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">e</span><span class="o">,</span> <span class="nx">oSelf</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">elTarget</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">getTarget</span><span class="o">(</span><span class="nx">e</span><span class="o">);</span>
        <span class="k">var</span> <span class="nx">elTag</span> <span class="o">=</span> <span class="nx">elTarget</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">();</span>
        <span class="k">var</span> <span class="nx">knownTag</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>

        <span class="k">if</span> <span class="o">(</span><span class="nx">elTag</span> <span class="o">!=</span> <span class="s2">&quot;table&quot;</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">while</span><span class="o">(!</span><span class="nx">knownTag</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">switch</span><span class="o">(</span><span class="nx">elTag</span><span class="o">)</span> <span class="o">{</span>
                    <span class="nx">case</span> <span class="s2">&quot;body&quot;</span><span class="o">:</span>
                        <span class="nx">knownTag</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
                        <span class="k">break</span><span class="o">;</span>
                    <span class="nx">case</span> <span class="s2">&quot;td&quot;</span><span class="o">:</span>
                        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;cellMouseoutEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:</span><span class="nx">elTarget</span><span class="o">,</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
                        <span class="nx">knownTag</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
                        <span class="k">break</span><span class="o">;</span>
                    <span class="nx">case</span> <span class="s2">&quot;th&quot;</span><span class="o">:</span>
                        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;headCellMouseoutEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:</span><span class="nx">elTarget</span><span class="o">,</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
                        <span class="nx">knownTag</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
                        <span class="k">break</span><span class="o">;</span>
                    <span class="nx">default</span><span class="o">:</span>
                        <span class="k">break</span><span class="o">;</span>
                <span class="o">}</span>
                <span class="nx">elTarget</span> <span class="o">=</span> <span class="nx">elTarget</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">;</span>
                <span class="k">if</span><span class="o">(</span><span class="nx">elTarget</span><span class="o">)</span> <span class="o">{</span>
                    <span class="nx">elTag</span> <span class="o">=</span> <span class="nx">elTarget</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">();</span>
                <span class="o">}</span>
                <span class="k">else</span> <span class="o">{</span>
                    <span class="k">break</span><span class="o">;</span>
                <span class="o">}</span>
            <span class="o">}</span>
        <span class="o">}</span>
        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;tableMouseoutEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:</span><span class="nx">elTarget</span><span class="o">,</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Handles mousedown events on the TABLE element.</span>
<span class="c"> *</span>
<span class="c"> * @method _onMousedown</span>
<span class="c"> * @param e {HTMLEvent} The mousedown event.</span>
<span class="c"> * @param oSelf {YAHOO.widget.DataTable} DataTable instance.</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_onMousedown</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">e</span><span class="o">,</span> <span class="nx">oSelf</span><span class="o">)</span> <span class="o">{</span>
        <span class="c">//YAHOO.util.Event.stopEvent(e);</span>
<span class="c"></span>        <span class="k">var</span> <span class="nx">elTarget</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">getTarget</span><span class="o">(</span><span class="nx">e</span><span class="o">);</span>
        <span class="k">var</span> <span class="nx">elTag</span> <span class="o">=</span> <span class="nx">elTarget</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">();</span>
        <span class="k">var</span> <span class="nx">knownTag</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>

        <span class="k">if</span> <span class="o">(</span><span class="nx">elTag</span> <span class="o">!=</span> <span class="s2">&quot;table&quot;</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">while</span><span class="o">(!</span><span class="nx">knownTag</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">switch</span><span class="o">(</span><span class="nx">elTag</span><span class="o">)</span> <span class="o">{</span>
                    <span class="nx">case</span> <span class="s2">&quot;body&quot;</span><span class="o">:</span>
                        <span class="nx">knownTag</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
                        <span class="k">break</span><span class="o">;</span>
                    <span class="nx">case</span> <span class="s2">&quot;td&quot;</span><span class="o">:</span>
                        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">stopEvent</span><span class="o">(</span><span class="nx">e</span><span class="o">);</span>
                        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;cellMousedownEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:</span><span class="nx">elTarget</span><span class="o">,</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
                        <span class="nx">knownTag</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
                        <span class="k">break</span><span class="o">;</span>
                    <span class="nx">case</span> <span class="s2">&quot;th&quot;</span><span class="o">:</span>
                        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">stopEvent</span><span class="o">(</span><span class="nx">e</span><span class="o">);</span>
                        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;headCellMousedownEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:</span><span class="nx">elTarget</span><span class="o">,</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
                        <span class="nx">knownTag</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
                        <span class="k">break</span><span class="o">;</span>
                    <span class="nx">default</span><span class="o">:</span>
                        <span class="k">break</span><span class="o">;</span>
                <span class="o">}</span>
                <span class="nx">elTarget</span> <span class="o">=</span> <span class="nx">elTarget</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">;</span>
                <span class="k">if</span><span class="o">(</span><span class="nx">elTarget</span><span class="o">)</span> <span class="o">{</span>
                    <span class="nx">elTag</span> <span class="o">=</span> <span class="nx">elTarget</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">();</span>
                <span class="o">}</span>
                <span class="k">else</span> <span class="o">{</span>
                    <span class="k">break</span><span class="o">;</span>
                <span class="o">}</span>
            <span class="o">}</span>
        <span class="o">}</span>
        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;tableMousedownEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:</span><span class="nx">elTarget</span><span class="o">,</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Handles click events on the TABLE element.</span>
<span class="c"> *</span>
<span class="c"> * @method _onClick</span>
<span class="c"> * @param e {HTMLEvent} The click event.</span>
<span class="c"> * @param oSelf {YAHOO.widget.DataTable} DataTable instance.</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_onClick</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">e</span><span class="o">,</span> <span class="nx">oSelf</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">elTarget</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">getTarget</span><span class="o">(</span><span class="nx">e</span><span class="o">);</span>
    <span class="k">var</span> <span class="nx">elTag</span> <span class="o">=</span> <span class="nx">elTarget</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">();</span>
    <span class="k">var</span> <span class="nx">knownTag</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span> <span class="c">// True if event should stop propagating</span>
<span class="c"></span>
    <span class="k">if</span><span class="o">(</span><span class="nx">oSelf</span><span class="o">.</span><span class="nx">activeEditor</span><span class="o">)</span> <span class="o">{</span> <span class="c">//&amp;&amp; (oSelf.activeEditor.column != column)</span>
<span class="c"></span>        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">activeEditor</span><span class="o">.</span><span class="nx">hide</span><span class="o">();</span>
        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">activeEditor</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>

        <span class="c">// Editor causes widget to lose focus</span>
<span class="c"></span>        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_bFocused</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">focusTable</span><span class="o">();</span>
    <span class="o">}</span>

    <span class="k">if</span> <span class="o">(</span><span class="nx">elTag</span> <span class="o">!=</span> <span class="s2">&quot;table&quot;</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">while</span><span class="o">(!</span><span class="nx">knownTag</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">switch</span><span class="o">(</span><span class="nx">elTag</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">case</span> <span class="s2">&quot;body&quot;</span><span class="o">:</span>
                    <span class="nx">knownTag</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
                    <span class="k">break</span><span class="o">;</span>
                <span class="nx">case</span> <span class="s2">&quot;input&quot;</span><span class="o">:</span>
                    <span class="k">if</span><span class="o">(</span><span class="nx">elTarget</span><span class="o">.</span><span class="nx">type</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">()</span> <span class="o">==</span> <span class="s2">&quot;checkbox&quot;</span><span class="o">)</span> <span class="o">{</span>
                        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;checkboxClickEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:</span><span class="nx">elTarget</span><span class="o">,</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
                    <span class="o">}</span>
                    <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">elTarget</span><span class="o">.</span><span class="nx">type</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">()</span> <span class="o">==</span> <span class="s2">&quot;radio&quot;</span><span class="o">)</span> <span class="o">{</span>
                        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;radioClickEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:</span><span class="nx">elTarget</span><span class="o">,</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
                    <span class="o">}</span>
                    <span class="nx">knownTag</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
                    <span class="k">break</span><span class="o">;</span>
                <span class="nx">case</span> <span class="s2">&quot;td&quot;</span><span class="o">:</span>
                    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">stopEvent</span><span class="o">(</span><span class="nx">e</span><span class="o">);</span>
                    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;cellClickEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:</span><span class="nx">elTarget</span><span class="o">,</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
                    <span class="nx">knownTag</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
                    <span class="k">break</span><span class="o">;</span>
                <span class="nx">case</span> <span class="s2">&quot;th&quot;</span><span class="o">:</span>
                    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">stopEvent</span><span class="o">(</span><span class="nx">e</span><span class="o">);</span>
                    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;headCellClickEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:</span><span class="nx">elTarget</span><span class="o">,</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
                    <span class="nx">knownTag</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
                    <span class="k">break</span><span class="o">;</span>
                <span class="nx">default</span><span class="o">:</span>
                    <span class="k">break</span><span class="o">;</span>
            <span class="o">}</span>
            <span class="nx">elTarget</span> <span class="o">=</span> <span class="nx">elTarget</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">;</span>
            <span class="nx">elTag</span> <span class="o">=</span> <span class="nx">elTarget</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">();</span>
        <span class="o">}</span>
    <span class="o">}</span>
    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">focusTable</span><span class="o">();</span>
    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;tableClickEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:</span><span class="nx">elTarget</span><span class="o">,</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Handles doubleclick events on the TABLE element.</span>
<span class="c"> *</span>
<span class="c"> * @method _onDoubleclick</span>
<span class="c"> * @param e {HTMLEvent} The doubleclick event.</span>
<span class="c"> * @param oSelf {YAHOO.widget.DataTable} DataTable instance.</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_onDoubleclick</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">e</span><span class="o">,</span> <span class="nx">oSelf</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">elTarget</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">getTarget</span><span class="o">(</span><span class="nx">e</span><span class="o">);</span>
    <span class="k">var</span> <span class="nx">elTag</span> <span class="o">=</span> <span class="nx">elTarget</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">();</span>
    <span class="k">var</span> <span class="nx">knownTag</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>

    <span class="k">if</span><span class="o">(</span><span class="nx">oSelf</span><span class="o">.</span><span class="nx">activeEditor</span><span class="o">)</span> <span class="o">{</span> <span class="c">//&amp;&amp; (oSelf.activeEditor.column != column)</span>
<span class="c"></span>        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">activeEditor</span><span class="o">.</span><span class="nx">hide</span><span class="o">();</span>
        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">activeEditor</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
        
        <span class="c">// Editor causes widget to lose focus</span>
<span class="c"></span>        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_bFocused</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">focusTable</span><span class="o">();</span>
    <span class="o">}</span>

    <span class="k">if</span> <span class="o">(</span><span class="nx">elTag</span> <span class="o">!=</span> <span class="s2">&quot;table&quot;</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">while</span><span class="o">(!</span><span class="nx">knownTag</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">switch</span><span class="o">(</span><span class="nx">elTag</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">case</span> <span class="s2">&quot;body&quot;</span><span class="o">:</span>
                    <span class="nx">knownTag</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
                    <span class="k">break</span><span class="o">;</span>
                <span class="nx">case</span> <span class="s2">&quot;td&quot;</span><span class="o">:</span>
                    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">stopEvent</span><span class="o">(</span><span class="nx">e</span><span class="o">);</span>
                    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;cellDoubleclickEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:</span><span class="nx">elTarget</span><span class="o">,</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
                    <span class="nx">knownTag</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
                    <span class="k">break</span><span class="o">;</span>
                <span class="nx">case</span> <span class="s2">&quot;th&quot;</span><span class="o">:</span>
                    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">stopEvent</span><span class="o">(</span><span class="nx">e</span><span class="o">);</span>
                    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;headCellDoubleclickEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:</span><span class="nx">elTarget</span><span class="o">,</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
                    <span class="nx">knownTag</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
                    <span class="k">break</span><span class="o">;</span>
                <span class="nx">default</span><span class="o">:</span>
                    <span class="k">break</span><span class="o">;</span>
            <span class="o">}</span>
            <span class="nx">elTarget</span> <span class="o">=</span> <span class="nx">elTarget</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">;</span>
            <span class="nx">elTag</span> <span class="o">=</span> <span class="nx">elTarget</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">();</span>
        <span class="o">}</span>
    <span class="o">}</span>
    <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;tableDoubleclickEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:</span><span class="nx">elTarget</span><span class="o">,</span><span class="nx">event</span><span class="o">:</span><span class="nx">e</span><span class="o">});</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Handles keypress events on the TABLE. Mainly to support stopEvent on Mac.</span>
<span class="c"> *</span>
<span class="c"> * @method _onKeypress</span>
<span class="c"> * @param e {HTMLEvent} The key event.</span>
<span class="c"> * @param oSelf {YAHOO.widget.DataTable} DataTable instance.</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_onKeypress</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">e</span><span class="o">,</span> <span class="nx">oSelf</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">isMac</span> <span class="o">=</span> <span class="o">(</span><span class="nx">navigator</span><span class="o">.</span><span class="nx">userAgent</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">().</span><span class="nx">indexOf</span><span class="o">(</span><span class="s2">&quot;mac&quot;</span><span class="o">)</span> <span class="o">!=</span> <span class="o">-</span><span class="m">1</span><span class="o">);</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">isMac</span><span class="o">)</span> <span class="o">{</span>
        <span class="c">// arrow down</span>
<span class="c"></span>        <span class="k">if</span><span class="o">(</span><span class="nx">e</span><span class="o">.</span><span class="nx">keyCode</span> <span class="o">==</span> <span class="m">40</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">stopEvent</span><span class="o">(</span><span class="nx">e</span><span class="o">);</span>
        <span class="o">}</span>
        <span class="c">// arrow up</span>
<span class="c"></span>        <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">e</span><span class="o">.</span><span class="nx">keyCode</span> <span class="o">==</span> <span class="m">38</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">stopEvent</span><span class="o">(</span><span class="nx">e</span><span class="o">);</span>
        <span class="o">}</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Handles keydown events on the TABLE. Executes arrow selection.</span>
<span class="c"> *</span>
<span class="c"> * @method _onKeydown</span>
<span class="c"> * @param e {HTMLEvent} The key event.</span>
<span class="c"> * @param oSelf {YAHOO.widget.DataTable} DataTable instance.</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_onKeydown</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">e</span><span class="o">,</span> <span class="nx">oSelf</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">oldSelected</span> <span class="o">=</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_lastSelected</span><span class="o">;</span>
    <span class="c">// Only move selection if one is already selected</span>
<span class="c"></span>    <span class="c">// TODO: config to allow selection even if one is NOT already selected</span>
<span class="c"></span>    <span class="c">// TODO: if something isn&#39;t selected already, arrow key should select first or last one</span>
<span class="c"></span>    <span class="k">if</span><span class="o">(</span><span class="nx">oldSelected</span> <span class="o">&amp;&amp;</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">isSelected</span><span class="o">(</span><span class="nx">oldSelected</span><span class="o">))</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">newSelected</span><span class="o">;</span>
        <span class="c">// arrow down</span>
<span class="c"></span>        <span class="k">if</span><span class="o">(</span><span class="nx">e</span><span class="o">.</span><span class="nx">keyCode</span> <span class="o">==</span> <span class="m">40</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">stopEvent</span><span class="o">(</span><span class="nx">e</span><span class="o">);</span>
            <span class="c">// row mode</span>
<span class="c"></span>            <span class="k">if</span><span class="o">(</span><span class="nx">oldSelected</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">()</span> <span class="o">==</span> <span class="s2">&quot;tr&quot;</span><span class="o">)</span> <span class="o">{</span>
                <span class="c">// We have room to move down</span>
<span class="c"></span>                <span class="k">if</span><span class="o">(</span><span class="nx">oldSelected</span><span class="o">.</span><span class="nx">sectionRowIndex</span><span class="o">+</span><span class="m">1</span> <span class="o">&lt;</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_elBody</span><span class="o">.</span><span class="nx">rows</span><span class="o">.</span><span class="nx">length</span><span class="o">)</span> <span class="o">{</span>
                            <span class="k">if</span><span class="o">(!</span><span class="nx">e</span><span class="o">.</span><span class="nx">shiftKey</span><span class="o">)</span> <span class="o">{</span>
                                <span class="nx">oSelf</span><span class="o">.</span><span class="nx">unselectAllRows</span><span class="o">();</span>
                            <span class="o">}</span>
                            <span class="nx">newSelected</span> <span class="o">=</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_elBody</span><span class="o">.</span><span class="nx">rows</span><span class="o">[</span><span class="nx">oldSelected</span><span class="o">.</span><span class="nx">sectionRowIndex</span><span class="o">+</span><span class="m">1</span><span class="o">];</span>
                            <span class="nx">oSelf</span><span class="o">.</span><span class="nx">select</span><span class="o">(</span><span class="nx">newSelected</span><span class="o">);</span>
                            
                <span class="o">}</span>
            <span class="o">}</span>
            <span class="c">// cell mode</span>
<span class="c"></span>            <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">oldSelected</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">()</span> <span class="o">==</span> <span class="s2">&quot;td&quot;</span><span class="o">)</span> <span class="o">{</span>
                <span class="c">/*// We have room to move down</span>
<span class="c">                if(oldSelected.sectionRowIndex+1 &lt; oSelf._elBody.rows.length) {</span>
<span class="c">                            if(!e.shiftKey) {</span>
<span class="c">                                oSelf.unselectAllRows();</span>
<span class="c">                            }</span>
<span class="c">                            newSelected = oSelf._elBody.rows[oldSelected.sectionRowIndex+1];</span>
<span class="c">                            oSelf.select(newSelected);</span>
<span class="c">                }*/</span>
            <span class="o">}</span>
            <span class="c">// Arrows can cause widget to lose focus</span>
<span class="c"></span>            <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_bFocused</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
            <span class="nx">oSelf</span><span class="o">.</span><span class="nx">focusTable</span><span class="o">();</span>
        <span class="o">}</span>
        <span class="c">// arrow up</span>
<span class="c"></span>        <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">e</span><span class="o">.</span><span class="nx">keyCode</span> <span class="o">==</span> <span class="m">38</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">stopEvent</span><span class="o">(</span><span class="nx">e</span><span class="o">);</span>
            <span class="c">// row mode</span>
<span class="c"></span>            <span class="k">if</span><span class="o">(</span><span class="nx">oldSelected</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">()</span> <span class="o">==</span> <span class="s2">&quot;tr&quot;</span><span class="o">)</span> <span class="o">{</span>
                <span class="c">// We have room to move up</span>
<span class="c"></span>                <span class="k">if</span><span class="o">((</span><span class="nx">oldSelected</span><span class="o">.</span><span class="nx">sectionRowIndex</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">))</span> <span class="o">{</span>
                            <span class="k">if</span><span class="o">(!</span><span class="nx">e</span><span class="o">.</span><span class="nx">shiftKey</span><span class="o">)</span> <span class="o">{</span>
                                <span class="nx">oSelf</span><span class="o">.</span><span class="nx">unselectAllRows</span><span class="o">();</span>
                            <span class="o">}</span>
                            <span class="nx">newSelected</span> <span class="o">=</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_elBody</span><span class="o">.</span><span class="nx">rows</span><span class="o">[</span><span class="nx">oldSelected</span><span class="o">.</span><span class="nx">sectionRowIndex</span><span class="o">-</span><span class="m">1</span><span class="o">];</span>
                            <span class="nx">oSelf</span><span class="o">.</span><span class="nx">select</span><span class="o">(</span><span class="nx">newSelected</span><span class="o">);</span>
                <span class="o">}</span>
            <span class="o">}</span>
            <span class="c">// cell mode</span>
<span class="c"></span>            <span class="k">else</span> <span class="k">if</span><span class="o">(</span><span class="nx">oldSelected</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">()</span> <span class="o">==</span> <span class="s2">&quot;td&quot;</span><span class="o">)</span> <span class="o">{</span>
                <span class="c">// We have room to move up</span>
<span class="c"></span>                <span class="k">if</span><span class="o">((</span><span class="nx">oldSelected</span><span class="o">.</span><span class="nx">sectionRowIndex</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">))</span> <span class="o">{</span>
                            <span class="k">if</span><span class="o">(!</span><span class="nx">e</span><span class="o">.</span><span class="nx">shiftKey</span><span class="o">)</span> <span class="o">{</span>
                                <span class="nx">oSelf</span><span class="o">.</span><span class="nx">unselectAllRows</span><span class="o">();</span>
                            <span class="o">}</span>
                            <span class="nx">newSelected</span> <span class="o">=</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_elBody</span><span class="o">.</span><span class="nx">rows</span><span class="o">[</span><span class="nx">oldSelected</span><span class="o">.</span><span class="nx">sectionRowIndex</span><span class="o">-</span><span class="m">1</span><span class="o">];</span>
                            <span class="nx">oSelf</span><span class="o">.</span><span class="nx">select</span><span class="o">(</span><span class="nx">newSelected</span><span class="o">);</span>
                <span class="o">}</span>
            <span class="o">}</span>
            <span class="c">// Arrows can cause widget to lose focus</span>
<span class="c"></span>            <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_bFocused</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
            <span class="nx">oSelf</span><span class="o">.</span><span class="nx">focusTable</span><span class="o">();</span>
        <span class="o">}</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Handles keyup events on the TABLE. Executes deletion</span>
<span class="c"> *</span>
<span class="c"> * @method _onKeyup</span>
<span class="c"> * @param e {HTMLEvent} The key event.</span>
<span class="c"> * @param oSelf {YAHOO.widget.DataTable} DataTable instance.</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_onKeyup</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">e</span><span class="o">,</span> <span class="nx">oSelf</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">key</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">getCharCode</span><span class="o">(</span><span class="nx">e</span><span class="o">);</span>
    <span class="c">// delete</span>
<span class="c"></span>    <span class="k">if</span><span class="o">(</span><span class="nx">key</span> <span class="o">==</span> <span class="m">46</span><span class="o">)</span> <span class="o">{</span><span class="c">//TODO: &amp;&amp; this.isFocused</span>
<span class="c"></span>        <span class="c">//TODO: delete row</span>
<span class="c"></span>    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Handles keyup events on the DOCUMENT. Executes interaction with editor.</span>
<span class="c"> *</span>
<span class="c"> * @method _onDocumentKeyup</span>
<span class="c"> * @param e {HTMLEvent} The key event.</span>
<span class="c"> * @param oSelf {YAHOO.widget.DataTable} DataTable instance.</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_onDocumentKeyup</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">e</span><span class="o">,</span> <span class="nx">oSelf</span><span class="o">)</span> <span class="o">{</span>
    <span class="c">// esc Clears active editor</span>
<span class="c"></span>    <span class="k">if</span><span class="o">((</span><span class="nx">e</span><span class="o">.</span><span class="nx">keyCode</span> <span class="o">==</span> <span class="m">27</span><span class="o">)</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">oSelf</span><span class="o">.</span><span class="nx">activeEditor</span><span class="o">))</span> <span class="o">{</span>
        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">activeEditor</span><span class="o">.</span><span class="nx">hide</span><span class="o">();</span>
        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">activeEditor</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
        
        <span class="c">// Editor causes widget to lose focus</span>
<span class="c"></span>        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_bFocused</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">focusTable</span><span class="o">();</span>
    <span class="o">}</span>
    <span class="c">// enter Saves active editor data</span>
<span class="c"></span>    <span class="k">if</span><span class="o">((</span><span class="nx">e</span><span class="o">.</span><span class="nx">keyCode</span> <span class="o">==</span> <span class="m">13</span><span class="o">)</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">oSelf</span><span class="o">.</span><span class="nx">activeEditor</span><span class="o">))</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">elCell</span> <span class="o">=</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">activeEditor</span><span class="o">.</span><span class="nx">cell</span><span class="o">;</span>
        <span class="k">var</span> <span class="nx">oColumn</span> <span class="o">=</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">activeEditor</span><span class="o">.</span><span class="nx">column</span><span class="o">;</span>
        <span class="k">var</span> <span class="nx">oRecord</span> <span class="o">=</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">activeEditor</span><span class="o">.</span><span class="nx">record</span><span class="o">;</span>
        <span class="k">var</span> <span class="nx">oldValue</span> <span class="o">=</span> <span class="nx">oRecord</span><span class="o">[</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">key</span><span class="o">];</span>
        <span class="k">var</span> <span class="nx">newValue</span> <span class="o">=</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">activeEditor</span><span class="o">.</span><span class="nx">getValue</span><span class="o">();</span>
        
        <span class="c">//Update Record</span>
<span class="c"></span>        <span class="c">//TODO: Column.key may be null!</span>
<span class="c"></span>        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_oRecordSet</span><span class="o">.</span><span class="nx">updateRecord</span><span class="o">(</span><span class="nx">oRecord</span><span class="o">,</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">key</span><span class="o">,</span><span class="nx">newValue</span><span class="o">);</span>

        <span class="c">//Update cell</span>
<span class="c"></span>        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">formatCell</span><span class="o">(</span><span class="nx">elCell</span><span class="o">);</span>

        <span class="c">// Hide editor</span>
<span class="c"></span>        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">activeEditor</span><span class="o">.</span><span class="nx">hide</span><span class="o">();</span>
        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">activeEditor</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>

        <span class="c">// Editor causes widget to lose focus</span>
<span class="c"></span>        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">_bFocused</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">focusTable</span><span class="o">();</span>
        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;cellEditEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:</span><span class="nx">elCell</span><span class="o">,</span><span class="nx">oldData</span><span class="o">:</span><span class="nx">oldValue</span><span class="o">,</span><span class="nx">newData</span><span class="o">:</span><span class="nx">newValue</span><span class="o">});</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Handles click events on paginator links.</span>
<span class="c"> *</span>
<span class="c"> * @method _onPagerClick</span>
<span class="c"> * @param e {HTMLEvent} The click event.</span>
<span class="c"> * @param oSelf {YAHOO.widget.DataTable} DataTable instance.</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_onPagerClick</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">e</span><span class="o">,</span> <span class="nx">oSelf</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">elTarget</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">getTarget</span><span class="o">(</span><span class="nx">e</span><span class="o">);</span>
    <span class="k">var</span> <span class="nx">elTag</span> <span class="o">=</span> <span class="nx">elTarget</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">();</span>
    <span class="k">var</span> <span class="nx">knownTag</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span> <span class="c">// True if event should stop propagating</span>
<span class="c"></span>
    <span class="k">if</span> <span class="o">(</span><span class="nx">elTag</span> <span class="o">!=</span> <span class="s2">&quot;table&quot;</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">while</span><span class="o">(!</span><span class="nx">knownTag</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">switch</span><span class="o">(</span><span class="nx">elTag</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">case</span> <span class="s2">&quot;body&quot;</span><span class="o">:</span>
                    <span class="nx">knownTag</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
                    <span class="k">break</span><span class="o">;</span>
                <span class="nx">case</span> <span class="s2">&quot;a&quot;</span><span class="o">:</span>
                    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">stopEvent</span><span class="o">(</span><span class="nx">e</span><span class="o">);</span>
                    <span class="nx">switch</span><span class="o">(</span><span class="nx">elTarget</span><span class="o">.</span><span class="nx">className</span><span class="o">)</span> <span class="o">{</span>
                        <span class="nx">case</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_PAGELINK</span><span class="o">:</span>
                            <span class="nx">oSelf</span><span class="o">.</span><span class="nx">showPage</span><span class="o">(</span><span class="nb">parseInt</span><span class="o">(</span><span class="nx">elTarget</span><span class="o">.</span><span class="nx">innerHTML</span><span class="o">,</span><span class="m">10</span><span class="o">));</span>
                            <span class="k">break</span><span class="o">;</span>
                        <span class="nx">case</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_FIRSTLINK</span><span class="o">:</span>
                            <span class="nx">oSelf</span><span class="o">.</span><span class="nx">showPage</span><span class="o">(</span><span class="m">1</span><span class="o">);</span>
                            <span class="k">break</span><span class="o">;</span>
                        <span class="nx">case</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_LASTLINK</span><span class="o">:</span>
                            <span class="nx">oSelf</span><span class="o">.</span><span class="nx">showPage</span><span class="o">(</span><span class="nx">oSelf</span><span class="o">.</span><span class="nx">_totalPages</span><span class="o">);</span>
                            <span class="k">break</span><span class="o">;</span>
                        <span class="nx">case</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_PREVLINK</span><span class="o">:</span>
                            <span class="nx">oSelf</span><span class="o">.</span><span class="nx">showPage</span><span class="o">(</span><span class="nx">oSelf</span><span class="o">.</span><span class="nx">pageCurrent</span><span class="o">-</span><span class="m">1</span><span class="o">);</span>
                            <span class="k">break</span><span class="o">;</span>
                        <span class="nx">case</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_NEXTLINK</span><span class="o">:</span>
                            <span class="nx">oSelf</span><span class="o">.</span><span class="nx">showPage</span><span class="o">(</span><span class="nx">oSelf</span><span class="o">.</span><span class="nx">pageCurrent</span><span class="o">+</span><span class="m">1</span><span class="o">);</span>
                            <span class="k">break</span><span class="o">;</span>
                    <span class="o">}</span>
                    <span class="nx">knownTag</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
                    <span class="k">break</span><span class="o">;</span>
                <span class="nx">default</span><span class="o">:</span>
                    <span class="k">break</span><span class="o">;</span>
            <span class="o">}</span>
            <span class="nx">elTarget</span> <span class="o">=</span> <span class="nx">elTarget</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">;</span>
            <span class="k">if</span><span class="o">(</span><span class="nx">elTarget</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">elTag</span> <span class="o">=</span> <span class="nx">elTarget</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">();</span>
            <span class="o">}</span>
            <span class="k">else</span> <span class="o">{</span>
                <span class="k">break</span><span class="o">;</span>
            <span class="o">}</span>
        <span class="o">}</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Handles change events on paginator SELECT.</span>
<span class="c"> *</span>
<span class="c"> * @method _onPagerSelect</span>
<span class="c"> * @param e {HTMLEvent} The change event.</span>
<span class="c"> * @param oSelf {YAHOO.widget.DataTable} DataTable instance.</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_onPagerSelect</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">e</span><span class="o">,</span> <span class="nx">oSelf</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">elTarget</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">getTarget</span><span class="o">(</span><span class="nx">e</span><span class="o">);</span>
    <span class="k">var</span> <span class="nx">elTag</span> <span class="o">=</span> <span class="nx">elTarget</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">();</span>

    <span class="c">// How many rows per page</span>
<span class="c"></span>    <span class="k">var</span> <span class="nx">oldRowsPerPage</span> <span class="o">=</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">rowsPerPage</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">rowsPerPage</span> <span class="o">=</span> <span class="nb">parseInt</span><span class="o">(</span><span class="nx">elTarget</span><span class="o">[</span><span class="nx">elTarget</span><span class="o">.</span><span class="nx">selectedIndex</span><span class="o">].</span><span class="nx">text</span><span class="o">,</span><span class="m">10</span><span class="o">);</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">rowsPerPage</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">rowsPerPage</span> <span class="o">!=</span> <span class="nx">oSelf</span><span class="o">.</span><span class="nx">rowsPerPage</span><span class="o">))</span> <span class="o">{</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">rowsPerPage</span> <span class="o">&gt;</span> <span class="nx">oldRowsPerPage</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">oSelf</span><span class="o">.</span><span class="nx">pageCurrent</span> <span class="o">=</span> <span class="m">1</span><span class="o">;</span>
        <span class="o">}</span>
        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">rowsPerPage</span> <span class="o">=</span> <span class="nx">rowsPerPage</span><span class="o">;</span>
        <span class="nx">oSelf</span><span class="o">.</span><span class="nx">paginateRows</span><span class="o">();</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c">//</span>
<span class="c">// Private Custom Event Handlers</span>
<span class="c">//</span>
<span class="c">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c"></span>
<span class="c">/**</span>
<span class="c"> * Handles row delete events.</span>
<span class="c"> *</span>
<span class="c"> * @method _onRowDelete</span>
<span class="c"> * @param oArgs.rowIndexes {Number[]} The indexes of the deleted rows.</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_onRowDelete</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">oArgs</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">_restripeRows</span><span class="o">();</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Passes along recordSetUpdate Event when recordUpdateEvent is caught from RecordSet.</span>
<span class="c"> *</span>
<span class="c"> * @event _onRecordUpdate</span>
<span class="c"> * @param oArgs.record {YAHOO.widget.Record} The Record instance.</span>
<span class="c"> * @param oArgs.key {String} The Record key.</span>
<span class="c"> * @param oArgs.newData {Object} New data.</span>
<span class="c"> * @param oArgs.oldData {Object} New data.</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">_onRecordUpdate</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">oArgs</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;recordSetUpdateEvent&quot;</span><span class="o">,</span><span class="nx">oArgs</span><span class="o">);</span>
<span class="o">};</span>

<span class="c">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c">//</span>
<span class="c">// Public member variables</span>
<span class="c">//</span>
<span class="c">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c"></span>
<span class="c">/**</span>
<span class="c"> * DataSource instance.</span>
<span class="c"> *</span>
<span class="c"> * @property dataSource</span>
<span class="c"> * @type YAHOO.util.DataSource</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">dataSource</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Initial request to send to DataSource.</span>
<span class="c"> *</span>
<span class="c"> * @property initialRequest</span>
<span class="c"> * @type String</span>
<span class="c"> * @default &quot;&quot;</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">initialRequest</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Defines value of CAPTION attribute.</span>
<span class="c"> *</span>
<span class="c"> * @property caption</span>
<span class="c"> * @type String</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">caption</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Defines value of SUMMARY attribute.</span>
<span class="c"> *</span>
<span class="c"> * @property summary</span>
<span class="c"> * @type String</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">summary</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * True if DataTable&#39;s width is a fixed size.</span>
<span class="c"> *</span>
<span class="c"> * @property fixedWidth</span>
<span class="c"> * @type Boolean</span>
<span class="c"> * @default false</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">fixedWidth</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * True if TBODY should scroll while THEAD remains fixed.</span>
<span class="c"> *</span>
<span class="c"> * @property scrollable</span>
<span class="c"> * @type Boolean</span>
<span class="c"> * @default false</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">scrollable</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * True if only one row may be selected at a time.</span>
<span class="c"> *</span>
<span class="c"> * @property rowSingleSelect</span>
<span class="c"> * @type Boolean</span>
<span class="c"> * @default false</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">rowSingleSelect</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * ContextMenu instance.</span>
<span class="c"> *</span>
<span class="c"> * @property contextMenu</span>
<span class="c"> * @type YAHOO.widget.ContextMenu</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">contextMenu</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Current page number.</span>
<span class="c"> *</span>
<span class="c"> * @property pageCurrent</span>
<span class="c"> * @type Number</span>
<span class="c"> * @default 1</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">pageCurrent</span> <span class="o">=</span> <span class="m">1</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Rows per page.</span>
<span class="c"> *</span>
<span class="c"> * @property rowsPerPage</span>
<span class="c"> * @type Number</span>
<span class="c"> * @default 500</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">rowsPerPage</span> <span class="o">=</span> <span class="m">500</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Record index of first row of current page.</span>
<span class="c"> *</span>
<span class="c"> * @property startRecordIndex</span>
<span class="c"> * @type Number</span>
<span class="c"> * @default 1</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">startRecordIndex</span> <span class="o">=</span> <span class="m">1</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Maximum number of pagination page links to show. Any page links beyond this number are</span>
<span class="c"> * available through the &quot;&amp;lt;&quot; and &quot;&amp;gt;&quot; links. A negative value will display all page links.</span>
<span class="c"> *</span>
<span class="c"> * @property pageLinksLength</span>
<span class="c"> * @type Number</span>
<span class="c"> * @default -1</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">pageLinksLength</span> <span class="o">=</span> <span class="o">-</span><span class="m">1</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Options to show in the rows-per-page pagination dropdown, should be an array</span>
<span class="c"> * of numbers. Null or an empty array causes no dropdown to be displayed.</span>
<span class="c"> *</span>
<span class="c"> * @property rowsPerPageDropdown</span>
<span class="c"> * @type Number[]</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">rowsPerPageDropdown</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
        
<span class="c">/**</span>
<span class="c"> * First pagination page link.</span>
<span class="c"> *</span>
<span class="c"> * @property pageLinksStart</span>
<span class="c"> * @type Number</span>
<span class="c"> * @default 1</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">pageLinksStart</span> <span class="o">=</span> <span class="m">1</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * An array of DIV elements into which pagination elements can go.</span>
<span class="c"> *</span>
<span class="c"> * @property pagers</span>
<span class="c"> * @type HTMLElement[]</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">pagers</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * True if the DataTable is empty of data. False if DataTable is populated with</span>
<span class="c"> * data from RecordSet.</span>
<span class="c"> *</span>
<span class="c"> * @property isEmpty</span>
<span class="c"> * @type Boolean</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">isEmpty</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>

<span class="c">/**</span>
<span class="c"> * Object literal holds sort metadata:</span>
<span class="c"> *  sortedBy.colKey</span>
<span class="c"> *  sortedBy.dir</span>
<span class="c"> *</span>
<span class="c"> *</span>
<span class="c"> * @property sortedBy</span>
<span class="c"> * @type Object</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">sortedBy</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>


<span class="c">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c">//</span>
<span class="c">// Public methods</span>
<span class="c">//</span>
<span class="c">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c"></span>
<span class="c">/**</span>
<span class="c"> * Public accessor to the unique name of the DataSource instance.</span>
<span class="c"> *</span>
<span class="c"> * @method toString</span>
<span class="c"> * @return {String} Unique name of the DataSource instance.</span>
<span class="c"> */</span>

<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">toString</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="k">return</span> <span class="s2">&quot;DataTable &quot;</span> <span class="o">+</span> <span class="k">this</span><span class="o">.</span><span class="nx">_sName</span><span class="o">;</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Returns element reference to TABLE.</span>
<span class="c"> *</span>
<span class="c"> * @method getTable</span>
<span class="c"> * @return {HTMLElement} Reference to TABLE element.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">getTable</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="k">return</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_elTable</span><span class="o">);</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Returns element reference to THEAD.</span>
<span class="c"> *</span>
<span class="c"> * @method getHead</span>
<span class="c"> * @return {HTMLElement} Reference to THEAD element.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">getHead</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="k">return</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_elHead</span><span class="o">);</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Returns element reference to TBODY.</span>
<span class="c"> *</span>
<span class="c"> * @method getBody</span>
<span class="c"> * @return {HTMLElement} Reference to TBODY element.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">getBody</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="k">return</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_elBody</span><span class="o">);</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Returns element reference to given TR cell.</span>
<span class="c"> *</span>
<span class="c"> * @method getRow</span>
<span class="c"> * @param index {Number} Row number.</span>
<span class="c"> * @return {HTMLElement} Reference to TR element.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">getRow</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">index</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">return</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_elBody</span><span class="o">.</span><span class="nx">rows</span><span class="o">[</span><span class="nx">index</span><span class="o">]);</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Returns element reference to given TD cell.</span>
<span class="c"> *</span>
<span class="c"> * @method getCell</span>
<span class="c"> * @param row {Number} Row number.</span>
<span class="c"> * @param col {Number} Column number.</span>
<span class="c"> * @return {HTMLElement} Reference to TD element.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">getCell</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">row</span><span class="o">,</span> <span class="nx">col</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">return</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_elBody</span><span class="o">.</span><span class="nx">rows</span><span class="o">[</span><span class="nx">row</span><span class="o">].</span><span class="nx">cells</span><span class="o">[</span><span class="nx">col</span><span class="o">]);</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Placeholder row to indicate table data is empty.</span>
<span class="c"> *</span>
<span class="c"> * @method showEmptyMessage</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">showEmptyMessage</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">isEmpty</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">return</span><span class="o">;</span>
    <span class="o">}</span>
    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">isLoading</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">hideTableMessages</span><span class="o">();</span>
    <span class="o">}</span>

    <span class="k">this</span><span class="o">.</span><span class="nx">_elMsgBody</span><span class="o">.</span><span class="nx">style</span><span class="o">.</span><span class="nx">display</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">elCell</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elMsgCell</span><span class="o">;</span>
    <span class="nx">elCell</span><span class="o">.</span><span class="nx">className</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_EMPTY</span><span class="o">;</span>
    <span class="nx">elCell</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">MSG_EMPTY</span><span class="o">;</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">isEmpty</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Placeholder row to indicate table data is loading.</span>
<span class="c"> *</span>
<span class="c"> * @method showLoadingMessage</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">showLoadingMessage</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">isLoading</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">return</span><span class="o">;</span>
    <span class="o">}</span>
    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">isEmpty</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">hideTableMessages</span><span class="o">();</span>
    <span class="o">}</span>

    <span class="k">this</span><span class="o">.</span><span class="nx">_elMsgBody</span><span class="o">.</span><span class="nx">style</span><span class="o">.</span><span class="nx">display</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">elCell</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elMsgCell</span><span class="o">;</span>
    <span class="nx">elCell</span><span class="o">.</span><span class="nx">className</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_LOADING</span><span class="o">;</span>
    <span class="nx">elCell</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">MSG_LOADING</span><span class="o">;</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">isLoading</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Hide any placeholder message row.</span>
<span class="c"> *</span>
<span class="c"> * @method hideTableMessages</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">hideTableMessages</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="k">if</span><span class="o">(!</span><span class="k">this</span><span class="o">.</span><span class="nx">isEmpty</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="k">this</span><span class="o">.</span><span class="nx">isLoading</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">return</span><span class="o">;</span>
    <span class="o">}</span>

    <span class="k">this</span><span class="o">.</span><span class="nx">_elMsgBody</span><span class="o">.</span><span class="nx">style</span><span class="o">.</span><span class="nx">display</span> <span class="o">=</span> <span class="s2">&quot;none&quot;</span><span class="o">;</span>

    <span class="k">this</span><span class="o">.</span><span class="nx">isEmpty</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">isLoading</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Sets focus on the TABLE element.</span>
<span class="c"> *</span>
<span class="c"> * @method focusTable</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">focusTable</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">elTable</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elTable</span><span class="o">;</span>
    <span class="k">if</span><span class="o">(!</span><span class="k">this</span><span class="o">.</span><span class="nx">_bFocused</span><span class="o">)</span> <span class="o">{</span>
        <span class="c">// http://developer.mozilla.org/en/docs/index.php?title=Key-navigable_custom_DHTML_widgets</span>
<span class="c"></span>        <span class="c">// The timeout is necessary in both IE and Firefox 1.5, to prevent scripts from doing</span>
<span class="c"></span>        <span class="c">// strange unexpected things as the user clicks on buttons and other controls.</span>
<span class="c"></span>        <span class="nx">setTimeout</span><span class="o">(</span><span class="k">function</span><span class="o">()</span> <span class="o">{</span> <span class="nx">elTable</span><span class="o">.</span><span class="nx">focus</span><span class="o">();</span> <span class="o">},</span><span class="m">0</span><span class="o">);</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">_bFocused</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;tableFocusEvent&quot;</span><span class="o">);</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Overridable method gives implementers a hook to access data before</span>
<span class="c"> * it gets added to RecordSet and rendered to the TBODY.</span>
<span class="c"> *</span>
<span class="c"> * @method doBeforeLoadData</span>
<span class="c"> * @param sRequest {String} Original request.</span>
<span class="c"> * @param oResponse {Object} Response object.</span>
<span class="c"> * @return {Boolean} Return true to continue loading data into RecordSet and</span>
<span class="c"> * updating DataTable with new Records, false to cancel.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">doBeforeLoadData</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">sRequest</span><span class="o">,</span> <span class="nx">oResponse</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">return</span> <span class="kc">true</span><span class="o">;</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Add rows to bottom of table body.</span>
<span class="c"> *</span>
<span class="c"> * @method appendRow</span>
<span class="c"> * @param aRecords {YAHOO.widget.Record[]} Array of Records.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">appendRows</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">aRecords</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">aRecords</span> <span class="o">&amp;&amp;</span> <span class="nx">aRecords</span><span class="o">.</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">hideTableMessages</span><span class="o">();</span>

        <span class="k">var</span> <span class="nx">rowIds</span> <span class="o">=</span> <span class="o">[];</span>
        <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">aRecords</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
            <span class="k">var</span> <span class="nx">rowId</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_addRow</span><span class="o">(</span><span class="nx">aRecords</span><span class="o">[</span><span class="nx">i</span><span class="o">]);</span>
            <span class="nx">rowIds</span><span class="o">.</span><span class="nx">push</span><span class="o">(</span><span class="nx">rowId</span><span class="o">);</span>
        <span class="o">}</span>
        
        <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;rowAppendEvent&quot;</span><span class="o">,</span> <span class="o">{</span><span class="nx">rowIds</span><span class="o">:</span><span class="nx">rowIds</span><span class="o">});</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Add rows to top of table body.</span>
<span class="c"> *</span>
<span class="c"> * @method insertRows</span>
<span class="c"> * @param aRecords {YAHOO.widget.Record[]} Array of Records.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">insertRows</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">aRecords</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">aRecords</span> <span class="o">&amp;&amp;</span> <span class="nx">aRecords</span><span class="o">.</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">hideTableMessages</span><span class="o">();</span>

        <span class="k">var</span> <span class="nx">rowIds</span> <span class="o">=</span> <span class="o">[];</span>
        <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">aRecords</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
            <span class="k">var</span> <span class="nx">rowId</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_addRow</span><span class="o">(</span><span class="nx">aRecords</span><span class="o">[</span><span class="nx">i</span><span class="o">],</span><span class="m">0</span><span class="o">);</span>
            <span class="nx">rowIds</span><span class="o">.</span><span class="nx">push</span><span class="o">(</span><span class="nx">rowId</span><span class="o">);</span>
        <span class="o">}</span>
        
        <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;rowInsertEvent&quot;</span><span class="o">,</span> <span class="o">{</span><span class="nx">rowIds</span><span class="o">:</span><span class="nx">rowIds</span><span class="o">});</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Replaces existing rows of table body with new Records.</span>
<span class="c"> *</span>
<span class="c"> * @method replaceRows</span>
<span class="c"> * @param aRecords {YAHOO.widget.Record[]} Array of Records.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">replaceRows</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">aRecords</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">i</span><span class="o">;</span>
    
    <span class="k">if</span><span class="o">(</span><span class="nx">aRecords</span> <span class="o">&amp;&amp;</span> <span class="nx">aRecords</span><span class="o">.</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">hideTableMessages</span><span class="o">();</span>

        <span class="k">var</span> <span class="nx">elBody</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elBody</span><span class="o">;</span>
        <span class="k">var</span> <span class="nx">elRows</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elBody</span><span class="o">.</span><span class="nx">rows</span><span class="o">;</span>
        
        <span class="c">// Remove extra rows</span>
<span class="c"></span>        <span class="k">while</span><span class="o">(</span><span class="nx">elBody</span><span class="o">.</span><span class="nx">hasChildNodes</span><span class="o">()</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">elRows</span><span class="o">.</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="nx">aRecords</span><span class="o">.</span><span class="nx">length</span><span class="o">))</span> <span class="o">{</span>
            <span class="nx">elBody</span><span class="o">.</span><span class="nx">deleteRow</span><span class="o">(</span><span class="m">0</span><span class="o">);</span>
        <span class="o">}</span>
        
        <span class="c">// Unselect rows in the UI but keep tracking selected rows</span>
<span class="c"></span>        <span class="k">var</span> <span class="nx">selectedRecords</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getSelectedRecordIds</span><span class="o">();</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">selectedRecords</span><span class="o">.</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">_unselectAllRows</span><span class="o">();</span>
        <span class="o">}</span>
        
        <span class="k">var</span> <span class="nx">rowIds</span> <span class="o">=</span> <span class="o">[];</span>
        <span class="c">// Format in-place existing rows</span>
<span class="c"></span>        <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">elRows</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
            <span class="k">if</span><span class="o">(</span><span class="nx">aRecords</span><span class="o">[</span><span class="nx">i</span><span class="o">])</span> <span class="o">{</span>
                <span class="k">var</span> <span class="nx">oRecord</span> <span class="o">=</span> <span class="nx">aRecords</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>
                <span class="nx">rowIds</span><span class="o">.</span><span class="nx">push</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_updateRow</span><span class="o">(</span><span class="nx">oRecord</span><span class="o">,</span><span class="nx">i</span><span class="o">));</span>
            <span class="o">}</span>
        <span class="o">}</span>

        <span class="c">// Add rows as necessary</span>
<span class="c"></span>        <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">elRows</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">aRecords</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
            <span class="nx">rowIds</span><span class="o">.</span><span class="nx">push</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_addRow</span><span class="o">(</span><span class="nx">aRecords</span><span class="o">[</span><span class="nx">i</span><span class="o">]));</span>
        <span class="o">}</span>
        
        <span class="c">// Select any rows as necessary</span>
<span class="c"></span>        <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">selectedRecords</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
            <span class="k">var</span> <span class="nx">allRows</span> <span class="o">=</span> <span class="nx">elBody</span><span class="o">.</span><span class="nx">rows</span><span class="o">;</span>
            <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">j</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">j</span><span class="o">&lt;</span><span class="nx">allRows</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">j</span><span class="o">++)</span> <span class="o">{</span>
                <span class="k">if</span><span class="o">(</span><span class="nx">selectedRecords</span><span class="o">[</span><span class="nx">i</span><span class="o">]</span> <span class="o">==</span> <span class="nx">allRows</span><span class="o">[</span><span class="nx">j</span><span class="o">].</span><span class="nx">recordId</span><span class="o">)</span> <span class="o">{</span>
                    <span class="k">this</span><span class="o">.</span><span class="nx">_select</span><span class="o">([</span><span class="nx">allRows</span><span class="o">[</span><span class="nx">j</span><span class="o">]]);</span>
                <span class="o">}</span>
            <span class="o">}</span>
        <span class="o">}</span>
        
        <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;rowReplaceEvent&quot;</span><span class="o">,</span> <span class="o">{</span><span class="nx">rowIds</span><span class="o">:</span><span class="nx">rowIds</span><span class="o">});</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Convenience method to add a new row to table body at position index if given,</span>
<span class="c"> * or to the bottom otherwise.</span>
<span class="c"> *</span>
<span class="c"> * @method addRow</span>
<span class="c"> * @param oRecord {YAHOO.widget.Record} Record instance.</span>
<span class="c"> * @param index {Number} Position at which to add row.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">addRow</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">oRecord</span><span class="o">,</span> <span class="nx">index</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">oRecord</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">rowId</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_addRow</span><span class="o">(</span><span class="nx">oRecord</span><span class="o">,</span> <span class="nx">index</span><span class="o">);</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">index</span> <span class="o">!==</span> <span class="kc">undefined</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;rowInsertEvent&quot;</span><span class="o">,</span> <span class="o">{</span><span class="nx">rowIds</span><span class="o">:[</span><span class="nx">rowId</span><span class="o">]});</span>
        <span class="o">}</span>
        <span class="k">else</span> <span class="o">{</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;rowAppendEvent&quot;</span><span class="o">,</span> <span class="o">{</span><span class="nx">rowIds</span><span class="o">:[</span><span class="nx">rowId</span><span class="o">]});</span>
        <span class="o">}</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Updates existing row at position index with data from the given Record.</span>
<span class="c"> *</span>
<span class="c"> * @method updateRow</span>
<span class="c"> * @param oRecord {YAHOO.widget.Record} Record instance.</span>
<span class="c"> * @param index {Number} Position at which to update row.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">updateRow</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">oRecord</span><span class="o">,</span> <span class="nx">index</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">oRecord</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">rowId</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_updateRow</span><span class="o">(</span><span class="nx">oRecord</span><span class="o">,</span> <span class="nx">index</span><span class="o">);</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;rowUpdateEvent&quot;</span><span class="o">,</span> <span class="o">{</span><span class="nx">rowIds</span><span class="o">:[</span><span class="nx">rowId</span><span class="o">]});</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Calls delete on selected rows.</span>
<span class="c"> *</span>
<span class="c"> * @method deleteSelectedRows</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">deleteRows</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">rows</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">rowIndexes</span> <span class="o">=</span> <span class="o">[];</span>
    <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">rows</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">rowIndex</span> <span class="o">=</span> <span class="o">(</span><span class="nx">rows</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">sectionRowIndex</span> <span class="o">!==</span> <span class="kc">undefined</span><span class="o">)</span> <span class="o">?</span> <span class="nx">rows</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">sectionRowIndex</span> <span class="o">:</span> <span class="kc">null</span><span class="o">;</span>
        <span class="nx">rowIndexes</span><span class="o">.</span><span class="nx">push</span><span class="o">(</span><span class="nx">rowIndex</span><span class="o">);</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">_deleteRow</span><span class="o">(</span><span class="nx">rows</span><span class="o">[</span><span class="nx">i</span><span class="o">]);</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;rowDeleteEvent&quot;</span><span class="o">,</span> <span class="o">{</span><span class="nx">rowIndexes</span><span class="o">:</span><span class="nx">rowIndexes</span><span class="o">});</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Deletes a given row element as well its corresponding Record in the RecordSet.</span>
<span class="c"> *</span>
<span class="c"> * @method deleteRow</span>
<span class="c"> * @param elRow {element} HTML table row element reference.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">deleteRow</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">elRow</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">elRow</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">rowIndex</span> <span class="o">=</span> <span class="o">(</span><span class="nx">elRow</span><span class="o">.</span><span class="nx">sectionRowIndex</span> <span class="o">!==</span> <span class="kc">undefined</span><span class="o">)</span> <span class="o">?</span> <span class="nx">elRow</span><span class="o">.</span><span class="nx">sectionRowIndex</span> <span class="o">:</span> <span class="kc">null</span><span class="o">;</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">_deleteRow</span><span class="o">(</span><span class="nx">elRow</span><span class="o">);</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;rowDeleteEvent&quot;</span><span class="o">,</span> <span class="o">{</span><span class="nx">rowIndexes</span><span class="o">:[</span><span class="nx">rowIndex</span><span class="o">]});</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Sets one or more elements to the highlighted state.</span>
<span class="c"> *</span>
<span class="c"> * @method highlight</span>
<span class="c"> * @param els {HTMLElement | String | HTMLElement[] | String[]} HTML TR element</span>
<span class="c"> * reference, TR String ID, array of HTML TR element, or array of TR element IDs.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">highlight</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">els</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">els</span><span class="o">.</span><span class="nx">constructor</span> <span class="o">!=</span> <span class="nb">Array</span><span class="o">)</span> <span class="o">{</span>
        <span class="nx">els</span> <span class="o">=</span> <span class="o">[</span><span class="nx">els</span><span class="o">];</span>
    <span class="o">}</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">els</span><span class="o">,</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_HIGHLIGHT</span><span class="o">);</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;highlightEvent&quot;</span><span class="o">,{</span><span class="nx">els</span><span class="o">:</span><span class="nx">els</span><span class="o">});</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Sets one or more elements to the unhighlighted state.</span>
<span class="c"> *</span>
<span class="c"> * @method unhighlight</span>
<span class="c"> * @param els {HTMLElement | String | HTMLElement[] | String[]} HTML TR element</span>
<span class="c"> * reference, TR String ID, array of HTML TR element, or array of TR element IDs.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">unhighlight</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">els</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">els</span><span class="o">.</span><span class="nx">constructor</span> <span class="o">!=</span> <span class="nb">Array</span><span class="o">)</span> <span class="o">{</span>
        <span class="nx">els</span> <span class="o">=</span> <span class="o">[</span><span class="nx">els</span><span class="o">];</span>
    <span class="o">}</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">removeClass</span><span class="o">(</span><span class="nx">els</span><span class="o">,</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_HIGHLIGHT</span><span class="o">);</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;unhighlightEvent&quot;</span><span class="o">,{</span><span class="nx">els</span><span class="o">:</span><span class="nx">els</span><span class="o">});</span>
<span class="o">};</span>


<span class="c">/**</span>
<span class="c"> * Sets one or more elements to the selected state.</span>
<span class="c"> *</span>
<span class="c"> * @method select</span>
<span class="c"> * @param els {HTMLElement | String | HTMLElement[] | String[]} HTML TR element</span>
<span class="c"> * reference, TR String ID, array of HTML TR element, or array of TR element IDs.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">select</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">els</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">els</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">els</span><span class="o">.</span><span class="nx">constructor</span> <span class="o">!=</span> <span class="nb">Array</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">els</span> <span class="o">=</span> <span class="o">[</span><span class="nx">els</span><span class="o">];</span>
        <span class="o">}</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">_select</span><span class="o">(</span><span class="nx">els</span><span class="o">);</span>
        
        <span class="c">// Add Record ID to internal tracker</span>
<span class="c"></span>        <span class="k">var</span> <span class="nx">tracker</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_aSelectedRecords</span> <span class="o">||</span> <span class="o">[];</span>
        <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">els</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
            <span class="k">var</span> <span class="nx">id</span> <span class="o">=</span> <span class="nx">els</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">recordId</span><span class="o">;</span>
            <span class="c">// Remove if already there</span>
<span class="c"></span>            <span class="c">// Use Array.indexOf if available...</span>
<span class="c"></span>            <span class="k">if</span><span class="o">(</span><span class="nx">tracker</span><span class="o">.</span><span class="nx">indexOf</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">tracker</span><span class="o">.</span><span class="nx">indexOf</span><span class="o">(</span><span class="nx">id</span><span class="o">)</span> <span class="o">&gt;</span>  <span class="o">-</span><span class="m">1</span><span class="o">))</span> <span class="o">{</span>
                <span class="nx">tracker</span><span class="o">.</span><span class="nx">splice</span><span class="o">(</span><span class="nx">tracker</span><span class="o">.</span><span class="nx">indexOf</span><span class="o">(</span><span class="nx">id</span><span class="o">),</span><span class="m">1</span><span class="o">);</span>
            <span class="o">}</span>
            <span class="c">// ...or do it the old-fashioned way</span>
<span class="c"></span>            <span class="k">else</span> <span class="o">{</span>
                <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">j</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">j</span><span class="o">&lt;</span><span class="nx">tracker</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">j</span><span class="o">++)</span> <span class="o">{</span>
                   <span class="k">if</span><span class="o">(</span><span class="nx">tracker</span><span class="o">[</span><span class="nx">j</span><span class="o">]</span> <span class="o">===</span> <span class="nx">id</span><span class="o">){</span>
                        <span class="nx">tracker</span><span class="o">.</span><span class="nx">splice</span><span class="o">(</span><span class="nx">j</span><span class="o">,</span><span class="m">1</span><span class="o">);</span>
                    <span class="o">}</span>
                <span class="o">}</span>
            <span class="o">}</span>
            <span class="c">// Add to the end</span>
<span class="c"></span>            <span class="nx">tracker</span><span class="o">.</span><span class="nx">push</span><span class="o">(</span><span class="nx">id</span><span class="o">);</span>
        <span class="o">}</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">_aSelectedRecords</span> <span class="o">=</span> <span class="nx">tracker</span><span class="o">;</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;selectEvent&quot;</span><span class="o">,{</span><span class="nx">els</span><span class="o">:</span><span class="nx">els</span><span class="o">});</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Sets one or more elements to the unselected state.</span>
<span class="c"> *</span>
<span class="c"> * @method unselect</span>
<span class="c"> * @param els {HTMLElement | String | HTMLElement[] | String[]} HTML element</span>
<span class="c"> * reference, element ID, array of HTML elements, or array of element IDs</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">unselect</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">els</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">els</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">els</span><span class="o">.</span><span class="nx">constructor</span> <span class="o">!=</span> <span class="nb">Array</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">els</span> <span class="o">=</span> <span class="o">[</span><span class="nx">els</span><span class="o">];</span>
        <span class="o">}</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">_unselect</span><span class="o">(</span><span class="nx">els</span><span class="o">);</span>
        <span class="c">// Remove Record ID from internal tracker</span>
<span class="c"></span>        <span class="k">var</span> <span class="nx">tracker</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_aSelectedRecords</span> <span class="o">||</span> <span class="o">[];</span>
        <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">els</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
            <span class="k">var</span> <span class="nx">id</span> <span class="o">=</span> <span class="nx">els</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">recordId</span><span class="o">;</span>
        
            <span class="c">// Use Array.indexOf if available...</span>
<span class="c"></span>            <span class="k">if</span><span class="o">(</span><span class="nx">tracker</span><span class="o">.</span><span class="nx">indexOf</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">tracker</span><span class="o">.</span><span class="nx">indexOf</span><span class="o">(</span><span class="nx">id</span><span class="o">)</span> <span class="o">&gt;</span>  <span class="o">-</span><span class="m">1</span><span class="o">))</span> <span class="o">{</span>
                <span class="nx">tracker</span><span class="o">.</span><span class="nx">splice</span><span class="o">(</span><span class="nx">tracker</span><span class="o">.</span><span class="nx">indexOf</span><span class="o">(</span><span class="nx">id</span><span class="o">),</span><span class="m">1</span><span class="o">);</span>
            <span class="o">}</span>
            <span class="c">// ...or do it the old-fashioned way</span>
<span class="c"></span>            <span class="k">else</span> <span class="o">{</span>
                <span class="k">for</span><span class="o">(</span><span class="k">var</span> <span class="nx">j</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">j</span><span class="o">&lt;</span><span class="nx">tracker</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">j</span><span class="o">++)</span> <span class="o">{</span>
                    <span class="k">if</span><span class="o">(</span><span class="nx">tracker</span><span class="o">[</span><span class="nx">j</span><span class="o">]</span> <span class="o">===</span> <span class="nx">id</span><span class="o">){</span>
                        <span class="nx">tracker</span><span class="o">.</span><span class="nx">splice</span><span class="o">(</span><span class="nx">j</span><span class="o">,</span><span class="m">1</span><span class="o">);</span>
                    <span class="o">}</span>
                <span class="o">}</span>
            <span class="o">}</span>
        <span class="o">}</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">_aSelectedRecords</span> <span class="o">=</span> <span class="nx">tracker</span><span class="o">;</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;unselectEvent&quot;</span><span class="o">,{</span><span class="nx">els</span><span class="o">:</span><span class="nx">els</span><span class="o">});</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Unselects all selected rows.</span>
<span class="c"> *</span>
<span class="c"> * @method unselectAllRows</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">unselectAllRows</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">selectedRows</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">getElementsByClassName</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_SELECTED</span><span class="o">,</span><span class="s2">&quot;tr&quot;</span><span class="o">,</span><span class="k">this</span><span class="o">.</span><span class="nx">_elBody</span><span class="o">);</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">unselect</span><span class="o">(</span><span class="nx">selectedRows</span><span class="o">);</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;unselectEvent&quot;</span><span class="o">,</span> <span class="o">{</span><span class="nx">els</span><span class="o">:</span><span class="nx">selectedRows</span><span class="o">});</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Unselects all selected cells.</span>
<span class="c"> *</span>
<span class="c"> * @method unselectAllCells</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">unselectAllCells</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">selectedCells</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">getElementsByClassName</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_SELECTED</span><span class="o">,</span><span class="s2">&quot;td&quot;</span><span class="o">,</span><span class="k">this</span><span class="o">.</span><span class="nx">_elBody</span><span class="o">);</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">unselect</span><span class="o">(</span><span class="nx">selectedCells</span><span class="o">);</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;unselectEvent&quot;</span><span class="o">,</span> <span class="o">{</span><span class="nx">els</span><span class="o">:</span><span class="nx">selectedCells</span><span class="o">});</span>
<span class="o">};</span>


<span class="c">/**</span>
<span class="c"> * Returns true if given element is select, false otherwise.</span>
<span class="c"> *</span>
<span class="c"> * @method isSelected</span>
<span class="c"> * @param el {element} HTML element reference.</span>
<span class="c"> * @return {boolean} True if element is selected.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">isSelected</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">return</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">hasClass</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_SELECTED</span><span class="o">);</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Returns array of selected Record IDs.</span>
<span class="c"> *</span>
<span class="c"> * @method getSelectedRecordIds</span>
<span class="c"> * @return {HTMLElement[]} Array of selected TR elements.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">getSelectedRecordIds</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="k">return</span> <span class="k">this</span><span class="o">.</span><span class="nx">_aSelectedRecords</span> <span class="o">||</span> <span class="o">[];</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Returns array of selected rows.</span>
<span class="c"> *</span>
<span class="c"> * @method getSelectedRows</span>
<span class="c"> * @return {HTMLElement[]} Array of selected TR elements.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">getSelectedRows</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="c">//TODO: keep internal array if this is non performant</span>
<span class="c"></span>    <span class="k">return</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">getElementsByClassName</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_SELECTED</span><span class="o">,</span><span class="s2">&quot;tr&quot;</span><span class="o">,</span><span class="k">this</span><span class="o">.</span><span class="nx">_elBody</span><span class="o">);</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Returns array of selected TD cells.</span>
<span class="c"> *</span>
<span class="c"> * @method getSelectedCells</span>
<span class="c"> * @return {HTMLElement[]} Array of selected TD elements.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">getSelectedCells</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="c">//TODO: keep internal array</span>
<span class="c"></span>    <span class="k">return</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">getElementsByClassName</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_SELECTED</span><span class="o">,</span><span class="s2">&quot;td&quot;</span><span class="o">,</span><span class="k">this</span><span class="o">.</span><span class="nx">_elBody</span><span class="o">);</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Returns pointer to the DataTable instance&#39;s ColumnSet instance.</span>
<span class="c"> *</span>
<span class="c"> * @method getColumnSet</span>
<span class="c"> * @return {YAHOO.widget.ColumnSet} ColumnSet instance.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">getColumnSet</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="k">return</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oColumnSet</span><span class="o">;</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Returns pointer to the DataTable instance&#39;s RecordSet instance.</span>
<span class="c"> *</span>
<span class="c"> * @method getRecordSet</span>
<span class="c"> * @return {YAHOO.widget.RecordSet} RecordSet instance.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">getRecordSet</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="k">return</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oRecordSet</span><span class="o">;</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Displays a specific page of a paginated DataTable.</span>
<span class="c"> *</span>
<span class="c"> * @method showPage</span>
<span class="c"> * @param nPage {Number} Which page.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">showPage</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">nPage</span><span class="o">)</span> <span class="o">{</span>
    <span class="c">// Validate input</span>
<span class="c"></span>    <span class="k">if</span><span class="o">(!</span><span class="nx">nPage</span> <span class="o">||</span> <span class="nb">isNaN</span><span class="o">(</span><span class="nx">nPage</span><span class="o">)</span> <span class="o">||</span> <span class="o">(</span><span class="nx">nPage</span> <span class="o">&lt;</span> <span class="m">1</span><span class="o">)</span> <span class="o">||</span> <span class="o">(</span><span class="nx">nPage</span> <span class="o">&gt;</span> <span class="k">this</span><span class="o">.</span><span class="nx">_totalPages</span><span class="o">))</span> <span class="o">{</span>
        <span class="nx">nPage</span> <span class="o">=</span> <span class="m">1</span><span class="o">;</span>
    <span class="o">}</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">pageCurrent</span> <span class="o">=</span> <span class="nx">nPage</span><span class="o">;</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">paginateRows</span><span class="o">();</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * If pagination is enabled, paginates all data in RecordSet and renders</span>
<span class="c"> * paginator UI, others renders normal TBODY without any paginator UI.</span>
<span class="c"> *</span>
<span class="c"> * @method paginateRows</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">paginateRows</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">i</span><span class="o">;</span>
    
    <span class="c">// How many total Records</span>
<span class="c"></span>    <span class="k">var</span> <span class="nx">recordsLength</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oRecordSet</span><span class="o">.</span><span class="nx">getLength</span><span class="o">();</span>
    
    <span class="c">// How many rows this page</span>
<span class="c"></span>    <span class="k">var</span> <span class="nx">maxRows</span> <span class="o">=</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">rowsPerPage</span> <span class="o">&lt;</span> <span class="nx">recordsLength</span><span class="o">)</span> <span class="o">?</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">rowsPerPage</span> <span class="o">:</span> <span class="nx">recordsLength</span><span class="o">;</span>

    <span class="c">// How many total pages</span>
<span class="c"></span>    <span class="k">this</span><span class="o">.</span><span class="nx">_totalPages</span> <span class="o">=</span> <span class="nb">Math</span><span class="o">.</span><span class="nx">ceil</span><span class="o">(</span><span class="nx">recordsLength</span> <span class="o">/</span> <span class="nx">maxRows</span><span class="o">);</span>

    <span class="c">// First row of this page</span>
<span class="c"></span>    <span class="k">this</span><span class="o">.</span><span class="nx">startRecordIndex</span> <span class="o">=</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">pageCurrent</span><span class="o">-</span><span class="m">1</span><span class="o">)</span> <span class="o">*</span> <span class="k">this</span><span class="o">.</span><span class="nx">rowsPerPage</span><span class="o">;</span>

    <span class="c">// How many page links to display</span>
<span class="c"></span>    <span class="k">var</span> <span class="nx">pageLinksLength</span> <span class="o">=</span>
            <span class="o">((</span><span class="k">this</span><span class="o">.</span><span class="nx">pageLinksLength</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">)</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">pageLinksLength</span> <span class="o">&lt;</span> <span class="k">this</span><span class="o">.</span><span class="nx">_totalPages</span><span class="o">))</span> <span class="o">?</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">pageLinksLength</span> <span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">_totalPages</span><span class="o">;</span>

    <span class="c">// First link of this page</span>
<span class="c"></span>    <span class="k">this</span><span class="o">.</span><span class="nx">pageLinksStart</span> <span class="o">=</span> <span class="o">(</span><span class="nb">Math</span><span class="o">.</span><span class="nx">ceil</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">pageCurrent</span><span class="o">/</span><span class="nx">pageLinksLength</span><span class="o">-</span><span class="m">1</span><span class="o">)</span> <span class="o">*</span> <span class="nx">pageLinksLength</span><span class="o">)</span> <span class="o">+</span> <span class="m">1</span><span class="o">;</span>

    <span class="c">// Show Records for this page</span>
<span class="c"></span>    <span class="k">var</span> <span class="nx">pageRecords</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oRecordSet</span><span class="o">.</span><span class="nx">getRecords</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">startRecordIndex</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">rowsPerPage</span><span class="o">);</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">replaceRows</span><span class="o">(</span><span class="nx">pageRecords</span><span class="o">);</span>

    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">rowsPerPage</span> <span class="o">&lt;</span> <span class="nx">recordsLength</span><span class="o">)</span> <span class="o">{</span>
        <span class="c">// Markup for page links</span>
<span class="c"></span>        <span class="k">var</span> <span class="nx">isFirstPage</span> <span class="o">=</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">pageCurrent</span> <span class="o">==</span> <span class="m">1</span><span class="o">)</span> <span class="o">?</span> <span class="kc">true</span> <span class="o">:</span> <span class="kc">false</span><span class="o">;</span>
        <span class="k">var</span> <span class="nx">isLastPage</span> <span class="o">=</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">pageCurrent</span> <span class="o">==</span> <span class="k">this</span><span class="o">.</span><span class="nx">_totalPages</span><span class="o">)</span> <span class="o">?</span> <span class="kc">true</span> <span class="o">:</span> <span class="kc">false</span><span class="o">;</span>
        <span class="k">var</span> <span class="nx">firstPageLink</span> <span class="o">=</span> <span class="o">(</span><span class="nx">isFirstPage</span><span class="o">)</span> <span class="o">?</span>
                <span class="s2">&quot; &lt;span class=\&quot;&quot;</span> <span class="o">+</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_FIRSTPAGE</span> <span class="o">+</span> <span class="s2">&quot;\&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &quot;</span> <span class="o">:</span>
                <span class="s2">&quot; &lt;a href=\&quot;#\&quot; class=\&quot;&quot;</span> <span class="o">+</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_FIRSTLINK</span> <span class="o">+</span> <span class="s2">&quot;\&quot;&gt;&amp;lt;&amp;lt;&lt;/a&gt; &quot;</span><span class="o">;</span>
        <span class="k">var</span> <span class="nx">prevPageLink</span> <span class="o">=</span> <span class="o">(</span><span class="nx">isFirstPage</span><span class="o">)</span> <span class="o">?</span>
                <span class="s2">&quot; &lt;span class=\&quot;&quot;</span> <span class="o">+</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_PREVPAGE</span> <span class="o">+</span> <span class="s2">&quot;\&quot;&gt;&amp;lt;&lt;/span&gt; &quot;</span> <span class="o">:</span>
                <span class="s2">&quot; &lt;a href=\&quot;#\&quot; class=\&quot;&quot;</span> <span class="o">+</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_PREVLINK</span> <span class="o">+</span> <span class="s2">&quot;\&quot;&gt;&amp;lt;&lt;/a&gt; &quot;</span> <span class="o">;</span>
        <span class="k">var</span> <span class="nx">nextPageLink</span> <span class="o">=</span> <span class="o">(</span><span class="nx">isLastPage</span><span class="o">)</span> <span class="o">?</span>
                <span class="s2">&quot; &lt;span class=\&quot;&quot;</span> <span class="o">+</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_NEXTPAGE</span> <span class="o">+</span> <span class="s2">&quot;\&quot;&gt;&amp;gt;&lt;/span&gt; &quot;</span> <span class="o">:</span>
                <span class="s2">&quot; &lt;a href=\&quot;#\&quot; class=\&quot;&quot;</span> <span class="o">+</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_NEXTLINK</span> <span class="o">+</span> <span class="s2">&quot;\&quot;&gt;&amp;gt;&lt;/a&gt; &quot;</span> <span class="o">;</span>
        <span class="k">var</span> <span class="nx">lastPageLink</span> <span class="o">=</span> <span class="o">(</span><span class="nx">isLastPage</span><span class="o">)</span> <span class="o">?</span>
                <span class="s2">&quot; &lt;span class=\&quot;&quot;</span> <span class="o">+</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_LASTPAGE</span> <span class="o">+</span> <span class="s2">&quot;\&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &quot;</span> <span class="o">:</span>
                <span class="s2">&quot; &lt;a href=\&quot;#\&quot; class=\&quot;&quot;</span> <span class="o">+</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_LASTLINK</span> <span class="o">+</span> <span class="s2">&quot;\&quot;&gt;&amp;gt;&amp;gt;&lt;/a&gt; &quot;</span><span class="o">;</span>
        <span class="k">var</span> <span class="nx">markup</span> <span class="o">=</span> <span class="nx">firstPageLink</span> <span class="o">+</span> <span class="nx">prevPageLink</span><span class="o">;</span>
        <span class="k">var</span> <span class="nx">maxLinks</span> <span class="o">=</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">pageLinksStart</span><span class="o">+</span><span class="nx">pageLinksLength</span> <span class="o">&lt;</span> <span class="k">this</span><span class="o">.</span><span class="nx">_totalPages</span><span class="o">)</span> <span class="o">?</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">pageLinksStart</span><span class="o">+</span><span class="nx">pageLinksLength</span><span class="o">-</span><span class="m">1</span> <span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">_totalPages</span><span class="o">;</span>
        <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="k">this</span><span class="o">.</span><span class="nx">pageLinksStart</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;=</span><span class="nx">maxLinks</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
             <span class="k">if</span><span class="o">(</span><span class="nx">i</span> <span class="o">!=</span> <span class="k">this</span><span class="o">.</span><span class="nx">pageCurrent</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">markup</span> <span class="o">+=</span> <span class="s2">&quot; &lt;a href=\&quot;#\&quot; class=\&quot;&quot;</span> <span class="o">+</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_PAGELINK</span> <span class="o">+</span> <span class="s2">&quot;\&quot;&gt;&quot;</span> <span class="o">+</span> <span class="nx">i</span> <span class="o">+</span> <span class="s2">&quot;&lt;/a&gt; &quot;</span><span class="o">;</span>
            <span class="o">}</span>
            <span class="k">else</span> <span class="o">{</span>
                <span class="nx">markup</span> <span class="o">+=</span> <span class="s2">&quot; &lt;span class=\&quot;&quot;</span> <span class="o">+</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_CURRENTPAGE</span> <span class="o">+</span> <span class="s2">&quot;\&quot;&gt;&quot;</span> <span class="o">+</span> <span class="nx">i</span> <span class="o">+</span> <span class="s2">&quot;&lt;/span&gt;&quot;</span><span class="o">;</span>
            <span class="o">}</span>
        <span class="o">}</span>
        <span class="nx">markup</span> <span class="o">+=</span> <span class="nx">nextPageLink</span> <span class="o">+</span> <span class="nx">lastPageLink</span><span class="o">;</span>

        <span class="c">// Markup for rows-per-page dropdowns</span>
<span class="c"></span>        <span class="k">var</span> <span class="nx">dropdown</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">rowsPerPageDropdown</span><span class="o">;</span>
        <span class="k">var</span> <span class="nx">select1</span><span class="o">,</span> <span class="nx">select2</span><span class="o">;</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">dropdown</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">dropdown</span><span class="o">.</span><span class="nx">constructor</span> <span class="o">==</span> <span class="nb">Array</span><span class="o">)</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">dropdown</span><span class="o">.</span><span class="nx">length</span> <span class="o">&gt;</span> <span class="m">0</span><span class="o">))</span> <span class="o">{</span>
            <span class="nx">select1</span> <span class="o">=</span> <span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;select&quot;</span><span class="o">);</span>
            <span class="nx">select1</span><span class="o">.</span><span class="nx">className</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_PAGESELECT</span><span class="o">;</span>
            <span class="nx">select2</span> <span class="o">=</span> <span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;select&quot;</span><span class="o">);</span>
            <span class="nx">select2</span><span class="o">.</span><span class="nx">className</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_PAGESELECT</span><span class="o">;</span>
            
            <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="nx">dropdown</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
                <span class="k">var</span> <span class="nx">option1</span> <span class="o">=</span> <span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;option&quot;</span><span class="o">);</span>
                <span class="k">var</span> <span class="nx">option2</span> <span class="o">=</span> <span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;option&quot;</span><span class="o">);</span>
                <span class="nx">option1</span><span class="o">.</span><span class="nx">value</span> <span class="o">=</span> <span class="nx">dropdown</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>
                <span class="nx">option2</span><span class="o">.</span><span class="nx">value</span> <span class="o">=</span> <span class="nx">dropdown</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>
                <span class="nx">option1</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="nx">dropdown</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>
                <span class="nx">option2</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="nx">dropdown</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>

                <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">rowsPerPage</span> <span class="o">===</span> <span class="nx">dropdown</span><span class="o">[</span><span class="nx">i</span><span class="o">])</span> <span class="o">{</span>
                    <span class="nx">option1</span><span class="o">.</span><span class="nx">selected</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
                    <span class="nx">option2</span><span class="o">.</span><span class="nx">selected</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
                <span class="o">}</span>
                <span class="nx">option1</span> <span class="o">=</span> <span class="nx">select1</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nx">option1</span><span class="o">);</span>
                <span class="nx">option2</span> <span class="o">=</span> <span class="nx">select2</span><span class="o">.</span><span class="nx">appendChild</span><span class="o">(</span><span class="nx">option2</span><span class="o">);</span>
            <span class="o">}</span>
        <span class="o">}</span>

        <span class="c">// Populate each pager container with markup</span>
<span class="c"></span>        <span class="k">if</span><span class="o">(!</span><span class="k">this</span><span class="o">.</span><span class="nx">pagers</span> <span class="o">||</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">pagers</span><span class="o">.</span><span class="nx">length</span> <span class="o">===</span> <span class="m">0</span><span class="o">))</span> <span class="o">{</span>
            <span class="k">var</span> <span class="nx">pager1</span> <span class="o">=</span> <span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;span&quot;</span><span class="o">);</span>
            <span class="nx">pager1</span><span class="o">.</span><span class="nx">className</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_PAGELINKS</span><span class="o">;</span>
            
            <span class="k">var</span> <span class="nx">pager2</span> <span class="o">=</span> <span class="nb">document</span><span class="o">.</span><span class="nx">createElement</span><span class="o">(</span><span class="s2">&quot;span&quot;</span><span class="o">);</span>
            <span class="nx">pager2</span><span class="o">.</span><span class="nx">className</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_PAGELINKS</span><span class="o">;</span>

            <span class="nx">pager1</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elContainer</span><span class="o">.</span><span class="nx">insertBefore</span><span class="o">(</span><span class="nx">pager1</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elTable</span><span class="o">);</span>
            <span class="nx">select1</span> <span class="o">=</span> <span class="o">(</span><span class="nx">select1</span> <span class="o">===</span> <span class="kc">undefined</span><span class="o">)</span> <span class="o">?</span> <span class="kc">null</span> <span class="o">:</span>
                    <span class="k">this</span><span class="o">.</span><span class="nx">_elContainer</span><span class="o">.</span><span class="nx">insertBefore</span><span class="o">(</span><span class="nx">select1</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elTable</span><span class="o">);</span>
            <span class="nx">select2</span> <span class="o">=</span> <span class="o">(</span><span class="nx">select2</span> <span class="o">===</span> <span class="kc">undefined</span><span class="o">)</span> <span class="o">?</span> <span class="kc">null</span> <span class="o">:</span>
                    <span class="k">this</span><span class="o">.</span><span class="nx">_elContainer</span><span class="o">.</span><span class="nx">insertBefore</span><span class="o">(</span><span class="nx">select2</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elTable</span><span class="o">.</span><span class="nx">nextSibling</span><span class="o">);</span>
            <span class="nx">pager2</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elContainer</span><span class="o">.</span><span class="nx">insertBefore</span><span class="o">(</span><span class="nx">pager2</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">_elTable</span><span class="o">.</span><span class="nx">nextSibling</span><span class="o">);</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">pagers</span> <span class="o">=</span> <span class="o">[</span>
                <span class="o">{</span><span class="nx">links</span><span class="o">:</span><span class="nx">pager1</span><span class="o">,</span><span class="nx">select</span><span class="o">:</span><span class="nx">select1</span><span class="o">},</span>
                <span class="o">{</span><span class="nx">links</span><span class="o">:</span><span class="nx">pager2</span><span class="o">,</span><span class="nx">select</span><span class="o">:</span><span class="nx">select2</span><span class="o">}</span>
            <span class="o">];</span>
        <span class="o">}</span>
        <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="m">0</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;</span><span class="k">this</span><span class="o">.</span><span class="nx">pagers</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">pagers</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">links</span><span class="o">.</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="nx">markup</span><span class="o">;</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">purgeElement</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">pagers</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">links</span><span class="o">);</span>
            <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">pagers</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">select</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">purgeElement</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">pagers</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">select</span><span class="o">);</span>
            <span class="o">}</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">pagers</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="nx">markup</span><span class="o">;</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">addListener</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">pagers</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">links</span><span class="o">,</span><span class="s2">&quot;click&quot;</span><span class="o">,</span><span class="k">this</span><span class="o">.</span><span class="nx">_onPagerClick</span><span class="o">,</span><span class="k">this</span><span class="o">);</span>
            <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">pagers</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">select</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">addListener</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">pagers</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">select</span><span class="o">,</span><span class="s2">&quot;change&quot;</span><span class="o">,</span><span class="k">this</span><span class="o">.</span><span class="nx">_onPagerSelect</span><span class="o">,</span><span class="k">this</span><span class="o">);</span>
            <span class="o">}</span>
        <span class="o">}</span>
    <span class="o">}</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;paginateEvent&quot;</span><span class="o">);</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Sort given column.</span>
<span class="c"> *</span>
<span class="c"> * @method sortColumn</span>
<span class="c"> * @param oColumn {YAHOO.widget.Column} Column to sort. TODO: accept the TH or TH.key</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">sortColumn</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">if</span><span class="o">(!</span><span class="nx">oColumn</span><span class="o">)</span> <span class="o">{</span>
        <span class="k">return</span><span class="o">;</span>
    <span class="o">}</span>
    <span class="k">if</span><span class="o">(!</span><span class="nx">oColumn</span> <span class="k">instanceof</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">Column</span><span class="o">)</span> <span class="o">{</span>
        <span class="c">//TODO: Figure out the column based on TH ref or TH.key</span>
<span class="c"></span>        <span class="k">return</span><span class="o">;</span>
    <span class="o">}</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">sortable</span><span class="o">)</span> <span class="o">{</span>
        <span class="c">// What is the default sort direction?</span>
<span class="c"></span>        <span class="k">var</span> <span class="nx">sortDir</span> <span class="o">=</span> <span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">sortOptions</span> <span class="o">&amp;&amp;</span> <span class="nx">oColumn</span><span class="o">.</span><span class="nx">sortOptions</span><span class="o">.</span><span class="nx">defaultOrder</span><span class="o">)</span> <span class="o">?</span> <span class="nx">oColumn</span><span class="o">.</span><span class="nx">sortOptions</span><span class="o">.</span><span class="nx">defaultOrder</span> <span class="o">:</span> <span class="s2">&quot;asc&quot;</span><span class="o">;</span>

        <span class="c">//TODO: what if column doesn&#39;t have key?</span>
<span class="c"></span>        <span class="c">// Is this column sorted already?</span>
<span class="c"></span>        <span class="k">if</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">key</span> <span class="o">&amp;&amp;</span> <span class="k">this</span><span class="o">.</span><span class="nx">sortedBy</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">sortedBy</span><span class="o">.</span><span class="nx">colKey</span> <span class="o">==</span> <span class="nx">oColumn</span><span class="o">.</span><span class="nx">key</span><span class="o">))</span> <span class="o">{</span>
            <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">sortedBy</span><span class="o">.</span><span class="nx">dir</span><span class="o">)</span> <span class="o">{</span>
                <span class="nx">sortDir</span> <span class="o">=</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">sortedBy</span><span class="o">.</span><span class="nx">dir</span> <span class="o">==</span> <span class="s2">&quot;asc&quot;</span><span class="o">)</span> <span class="o">?</span> <span class="s2">&quot;desc&quot;</span> <span class="o">:</span> <span class="s2">&quot;asc&quot;</span><span class="o">;</span>
            <span class="o">}</span>
            <span class="k">else</span> <span class="o">{</span>
                <span class="nx">sortDir</span> <span class="o">=</span> <span class="o">(</span><span class="nx">sortDir</span> <span class="o">==</span> <span class="s2">&quot;asc&quot;</span><span class="o">)</span> <span class="o">?</span> <span class="s2">&quot;desc&quot;</span> <span class="o">:</span> <span class="s2">&quot;asc&quot;</span><span class="o">;</span>
            <span class="o">}</span>
        <span class="o">}</span>
        <span class="k">else</span> <span class="k">if</span><span class="o">(!</span><span class="k">this</span><span class="o">.</span><span class="nx">sortedBy</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">sortedBy</span> <span class="o">=</span> <span class="o">{};</span>
        <span class="o">}</span>

        <span class="c">// Define the sort handler function based on the direction</span>
<span class="c"></span>        <span class="k">var</span> <span class="nx">sortFnc</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
        <span class="k">if</span><span class="o">((</span><span class="nx">sortDir</span> <span class="o">==</span> <span class="s2">&quot;desc&quot;</span><span class="o">)</span> <span class="o">&amp;&amp;</span> <span class="nx">oColumn</span><span class="o">.</span><span class="nx">sortOptions</span> <span class="o">&amp;&amp;</span> <span class="nx">oColumn</span><span class="o">.</span><span class="nx">sortOptions</span><span class="o">.</span><span class="nx">descFunction</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">sortFnc</span> <span class="o">=</span> <span class="nx">oColumn</span><span class="o">.</span><span class="nx">sortOptions</span><span class="o">.</span><span class="nx">descFunction</span><span class="o">;</span>
        <span class="o">}</span>
        <span class="k">else</span> <span class="k">if</span><span class="o">((</span><span class="nx">sortDir</span> <span class="o">==</span> <span class="s2">&quot;asc&quot;</span><span class="o">)</span> <span class="o">&amp;&amp;</span> <span class="nx">oColumn</span><span class="o">.</span><span class="nx">sortOptions</span> <span class="o">&amp;&amp;</span> <span class="nx">oColumn</span><span class="o">.</span><span class="nx">sortOptions</span><span class="o">.</span><span class="nx">ascFunction</span><span class="o">)</span> <span class="o">{</span>
            <span class="nx">sortFnc</span> <span class="o">=</span> <span class="nx">oColumn</span><span class="o">.</span><span class="nx">sortOptions</span><span class="o">.</span><span class="nx">ascFunction</span><span class="o">;</span>
        <span class="o">}</span>

        <span class="c">// Custom function was not provided so use the built-in sorter</span>
<span class="c"></span>        <span class="c">// ONLY IF column key is defined</span>
<span class="c"></span>        <span class="c">// TODO: use diff default functions based on column data type</span>
<span class="c"></span>        <span class="c">// TODO: nested/cumulative/hierarchical sorting</span>
<span class="c"></span>        <span class="k">if</span><span class="o">(!</span><span class="nx">sortFnc</span> <span class="o">&amp;&amp;</span> <span class="nx">oColumn</span><span class="o">.</span><span class="nx">key</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">var</span> <span class="nx">sorted</span><span class="o">;</span>
            <span class="nx">sortFnc</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">a</span><span class="o">,</span> <span class="nx">b</span><span class="o">)</span> <span class="o">{</span>
                <span class="k">if</span><span class="o">(</span><span class="nx">sortDir</span> <span class="o">==</span> <span class="s2">&quot;desc&quot;</span><span class="o">)</span> <span class="o">{</span>
                    <span class="nx">sorted</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Sort</span><span class="o">.</span><span class="nx">compareDesc</span><span class="o">(</span><span class="nx">a</span><span class="o">[</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">key</span><span class="o">],</span><span class="nx">b</span><span class="o">[</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">key</span><span class="o">]);</span>
                    <span class="k">if</span><span class="o">(</span><span class="nx">sorted</span> <span class="o">===</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
                        <span class="k">return</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Sort</span><span class="o">.</span><span class="nx">compareDesc</span><span class="o">(</span><span class="nx">a</span><span class="o">.</span><span class="nx">id</span><span class="o">,</span><span class="nx">b</span><span class="o">.</span><span class="nx">id</span><span class="o">);</span>
                    <span class="o">}</span>
                    <span class="k">else</span> <span class="o">{</span>
                        <span class="k">return</span> <span class="nx">sorted</span><span class="o">;</span>
                    <span class="o">}</span>
                <span class="o">}</span>
                <span class="k">else</span> <span class="o">{</span>
                    <span class="nx">sorted</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Sort</span><span class="o">.</span><span class="nx">compareAsc</span><span class="o">(</span><span class="nx">a</span><span class="o">[</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">key</span><span class="o">],</span><span class="nx">b</span><span class="o">[</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">key</span><span class="o">]);</span>
                    <span class="k">if</span><span class="o">(</span><span class="nx">sorted</span> <span class="o">===</span> <span class="m">0</span><span class="o">)</span> <span class="o">{</span>
                        <span class="k">return</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Sort</span><span class="o">.</span><span class="nx">compareAsc</span><span class="o">(</span><span class="nx">a</span><span class="o">.</span><span class="nx">id</span><span class="o">,</span><span class="nx">b</span><span class="o">.</span><span class="nx">id</span><span class="o">);</span>
                    <span class="o">}</span>
                    <span class="k">else</span> <span class="o">{</span>
                        <span class="k">return</span> <span class="nx">sorted</span><span class="o">;</span>
                    <span class="o">}</span>
                <span class="o">}</span>
            <span class="o">};</span>
        <span class="o">}</span>

        <span class="k">if</span><span class="o">(</span><span class="nx">sortFnc</span><span class="o">)</span> <span class="o">{</span>
            <span class="c">// Do the actual sort</span>
<span class="c"></span>            <span class="k">this</span><span class="o">.</span><span class="nx">_oRecordSet</span><span class="o">.</span><span class="nx">sort</span><span class="o">(</span><span class="nx">sortFnc</span><span class="o">);</span>

            <span class="c">// Update the UI</span>
<span class="c"></span>            <span class="k">this</span><span class="o">.</span><span class="nx">paginateRows</span><span class="o">();</span>

            <span class="c">// Update classes</span>
<span class="c"></span>            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">removeClass</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">sortedBy</span><span class="o">.</span><span class="nx">_id</span><span class="o">,</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_SORTEDBYASC</span><span class="o">);</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">removeClass</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">sortedBy</span><span class="o">.</span><span class="nx">_id</span><span class="o">,</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_SORTEDBYDESC</span><span class="o">);</span>
            <span class="k">var</span> <span class="nx">newClass</span> <span class="o">=</span> <span class="o">(</span><span class="nx">sortDir</span> <span class="o">==</span> <span class="s2">&quot;asc&quot;</span><span class="o">)</span> <span class="o">?</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_SORTEDBYASC</span> <span class="o">:</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">CLASS_SORTEDBYDESC</span><span class="o">;</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">oColumn</span><span class="o">.</span><span class="nx">getId</span><span class="o">(),</span> <span class="nx">newClass</span><span class="o">);</span>

            <span class="c">// Keep track of currently sorted column</span>
<span class="c"></span>            <span class="k">this</span><span class="o">.</span><span class="nx">sortedBy</span><span class="o">.</span><span class="nx">colKey</span> <span class="o">=</span> <span class="nx">oColumn</span><span class="o">.</span><span class="nx">key</span><span class="o">;</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">sortedBy</span><span class="o">.</span><span class="nx">dir</span> <span class="o">=</span> <span class="nx">sortDir</span><span class="o">;</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">sortedBy</span><span class="o">.</span><span class="nx">_id</span> <span class="o">=</span> <span class="nx">oColumn</span><span class="o">.</span><span class="nx">getId</span><span class="o">();</span>

            <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;columnSortEvent&quot;</span><span class="o">,{</span><span class="nx">column</span><span class="o">:</span><span class="nx">oColumn</span><span class="o">,</span><span class="nx">dir</span><span class="o">:</span><span class="nx">sortDir</span><span class="o">});</span>
        <span class="o">}</span>
    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>
        <span class="c">//TODO</span>
<span class="c"></span>        <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Column is not sortable&quot;</span><span class="o">,</span> <span class="s2">&quot;info&quot;</span><span class="o">,</span> <span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Shows editor for given cell.</span>
<span class="c"> *</span>
<span class="c"> * @method editCell</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">editCell</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">elCell</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">elCell</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nb">isNaN</span><span class="o">(</span><span class="nx">elCell</span><span class="o">.</span><span class="nx">columnIndex</span><span class="o">))</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">column</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oColumnSet</span><span class="o">.</span><span class="nx">keys</span><span class="o">[</span><span class="nx">elCell</span><span class="o">.</span><span class="nx">columnIndex</span><span class="o">];</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">column</span> <span class="o">&amp;&amp;</span> <span class="nx">column</span><span class="o">.</span><span class="nx">editor</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">activeEditor</span> <span class="o">=</span> <span class="nx">column</span><span class="o">.</span><span class="nx">getEditor</span><span class="o">(</span><span class="nx">elCell</span><span class="o">,</span><span class="k">this</span><span class="o">.</span><span class="nx">_oRecordSet</span><span class="o">.</span><span class="nx">getRecord</span><span class="o">(</span><span class="nx">elCell</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">.</span><span class="nx">recordId</span><span class="o">));</span>
        <span class="o">}</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">_bFocused</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;editorShowEvent&quot;</span><span class="o">,{</span><span class="nx">target</span><span class="o">:</span><span class="nx">elCell</span><span class="o">,</span><span class="nx">column</span><span class="o">:</span><span class="nx">column</span><span class="o">});</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Formats given cell.</span>
<span class="c"> *</span>
<span class="c"> * @method formatCell</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">formatCell</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">elCell</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">elCell</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nb">isNaN</span><span class="o">(</span><span class="nx">elCell</span><span class="o">.</span><span class="nx">columnIndex</span><span class="o">))</span> <span class="o">{</span>
        <span class="k">var</span> <span class="nx">column</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oColumnSet</span><span class="o">.</span><span class="nx">keys</span><span class="o">[</span><span class="nx">elCell</span><span class="o">.</span><span class="nx">columnIndex</span><span class="o">];</span>
        <span class="nx">column</span><span class="o">.</span><span class="nx">format</span><span class="o">(</span><span class="nx">elCell</span><span class="o">,</span><span class="k">this</span><span class="o">.</span><span class="nx">_oRecordSet</span><span class="o">.</span><span class="nx">getRecord</span><span class="o">(</span><span class="nx">elCell</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">.</span><span class="nx">recordId</span><span class="o">));</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;cellFormatEvent&quot;</span><span class="o">,</span> <span class="o">{</span><span class="nx">el</span><span class="o">:</span><span class="nx">elCell</span><span class="o">});</span>
    <span class="o">}</span>
<span class="o">};</span>


<span class="c">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c">//</span>
<span class="c">// Public Custom Event Handlers</span>
<span class="c">//</span>
<span class="c">/////////////////////////////////////////////////////////////////////////////</span>
<span class="c"></span>
<span class="c">/**</span>
<span class="c"> * Overridable custom event handler to sort column.</span>
<span class="c"> *</span>
<span class="c"> * @method onEventSortColumn</span>
<span class="c"> * @param oArgs.event {HTMLEvent} Event object.</span>
<span class="c"> * @param oArgs.target {HTMLElement} Target element.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">onEventSortColumn</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">oArgs</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">evt</span> <span class="o">=</span> <span class="nx">oArgs</span><span class="o">.</span><span class="nx">event</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">target</span> <span class="o">=</span> <span class="nx">oArgs</span><span class="o">.</span><span class="nx">target</span><span class="o">;</span>
    <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">stopEvent</span><span class="o">(</span><span class="nx">evt</span><span class="o">);</span>
    
    <span class="c">//TODO: traverse DOM to find a columnIndex, incl safety net if none exists</span>
<span class="c"></span>    <span class="k">var</span> <span class="nx">columnIndex</span> <span class="o">=</span> <span class="nx">target</span><span class="o">.</span><span class="nx">columnIndex</span><span class="o">;</span>
    <span class="k">if</span><span class="o">(!</span><span class="nb">isNaN</span><span class="o">(</span><span class="nx">columnIndex</span><span class="o">))</span> <span class="o">{</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">sortColumn</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_oColumnSet</span><span class="o">.</span><span class="nx">keys</span><span class="o">[</span><span class="nx">columnIndex</span><span class="o">]);</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Overridable custom event handler to select row.</span>
<span class="c"> *</span>
<span class="c"> * @method onEventSelectRow</span>
<span class="c"> * @param oArgs.event {HTMLEvent} Event object.</span>
<span class="c"> * @param oArgs.target {HTMLElement} Target element.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">onEventSelectRow</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">oArgs</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">i</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">evt</span> <span class="o">=</span> <span class="nx">oArgs</span><span class="o">.</span><span class="nx">event</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">target</span> <span class="o">=</span> <span class="nx">oArgs</span><span class="o">.</span><span class="nx">target</span><span class="o">;</span>

    <span class="c">//TODO: add a safety net in case TR is never reached</span>
<span class="c"></span>    <span class="c">// Walk up the DOM until we get to the TR</span>
<span class="c"></span>    <span class="k">while</span><span class="o">(</span><span class="nx">target</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">()</span> <span class="o">!=</span> <span class="s2">&quot;tr&quot;</span><span class="o">)</span> <span class="o">{</span>
        <span class="nx">target</span> <span class="o">=</span> <span class="nx">target</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">;</span>
    <span class="o">}</span>

    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">isSelected</span><span class="o">(</span><span class="nx">target</span><span class="o">))</span> <span class="o">{</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">unselect</span><span class="o">(</span><span class="nx">target</span><span class="o">);</span>
    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>
        <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">rowSingleSelect</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nx">evt</span><span class="o">.</span><span class="nx">ctrlKey</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nx">evt</span><span class="o">.</span><span class="nx">shiftKey</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">unselectAllRows</span><span class="o">();</span>
        <span class="o">}</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">evt</span><span class="o">.</span><span class="nx">shiftKey</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">var</span> <span class="nx">startRow</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_lastSelected</span><span class="o">;</span>
            <span class="k">if</span><span class="o">(</span><span class="nx">startRow</span> <span class="o">&amp;&amp;</span> <span class="k">this</span><span class="o">.</span><span class="nx">isSelected</span><span class="o">(</span><span class="nx">startRow</span><span class="o">))</span> <span class="o">{</span>
                <span class="k">this</span><span class="o">.</span><span class="nx">unselectAllRows</span><span class="o">();</span>
                <span class="k">if</span><span class="o">(</span><span class="nx">startRow</span><span class="o">.</span><span class="nx">sectionRowIndex</span> <span class="o">&lt;</span> <span class="nx">target</span><span class="o">.</span><span class="nx">sectionRowIndex</span><span class="o">)</span> <span class="o">{</span>
                    <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">startRow</span><span class="o">.</span><span class="nx">sectionRowIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;=</span><span class="nx">target</span><span class="o">.</span><span class="nx">sectionRowIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
                        <span class="k">this</span><span class="o">.</span><span class="nx">select</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_elBody</span><span class="o">.</span><span class="nx">rows</span><span class="o">[</span><span class="nx">i</span><span class="o">]);</span>
                    <span class="o">}</span>
                <span class="o">}</span>
                <span class="k">else</span> <span class="o">{</span>
                    <span class="k">for</span><span class="o">(</span><span class="nx">i</span><span class="o">=</span><span class="nx">target</span><span class="o">.</span><span class="nx">sectionRowIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">&lt;=</span><span class="nx">startRow</span><span class="o">.</span><span class="nx">sectionRowIndex</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
                        <span class="k">this</span><span class="o">.</span><span class="nx">select</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">_elBody</span><span class="o">.</span><span class="nx">rows</span><span class="o">[</span><span class="nx">i</span><span class="o">]);</span>
                    <span class="o">}</span>
                <span class="o">}</span>
            <span class="o">}</span>
            <span class="k">else</span> <span class="o">{</span>
                <span class="k">this</span><span class="o">.</span><span class="nx">select</span><span class="o">(</span><span class="nx">target</span><span class="o">);</span>
            <span class="o">}</span>
        <span class="o">}</span>
        <span class="k">else</span> <span class="o">{</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">select</span><span class="o">(</span><span class="nx">target</span><span class="o">);</span>
        <span class="o">}</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Overridable custom event handler to select cell.</span>
<span class="c"> *</span>
<span class="c"> * @method onEventSelectCell</span>
<span class="c"> * @param oArgs.event {HTMLEvent} Event object.</span>
<span class="c"> * @param oArgs.target {HTMLElement} Target element.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">onEventSelectCell</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">oArgs</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">evt</span> <span class="o">=</span> <span class="nx">oArgs</span><span class="o">.</span><span class="nx">event</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">target</span> <span class="o">=</span> <span class="nx">oArgs</span><span class="o">.</span><span class="nx">target</span><span class="o">;</span>

    <span class="c">//TODO: add a safety net in case TD is never reached</span>
<span class="c"></span>    <span class="c">// Walk up the DOM until we get to the TD</span>
<span class="c"></span>    <span class="k">while</span><span class="o">(</span><span class="nx">target</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">()</span> <span class="o">!=</span> <span class="s2">&quot;td&quot;</span><span class="o">)</span> <span class="o">{</span>
        <span class="nx">target</span> <span class="o">=</span> <span class="nx">target</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">;</span>
    <span class="o">}</span>

    <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">isSelected</span><span class="o">(</span><span class="nx">target</span><span class="o">))</span> <span class="o">{</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">unselect</span><span class="o">(</span><span class="nx">target</span><span class="o">);</span>
    <span class="o">}</span>
    <span class="k">else</span> <span class="o">{</span>
        <span class="k">if</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">rowSingleSelect</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nx">evt</span><span class="o">.</span><span class="nx">ctrlKey</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">unselectAllCells</span><span class="o">();</span>
        <span class="o">}</span>
        <span class="k">this</span><span class="o">.</span><span class="nx">select</span><span class="o">(</span><span class="nx">target</span><span class="o">);</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Overridable custom event handler to format cell.</span>
<span class="c"> *</span>
<span class="c"> * @method onEventFormatCell</span>
<span class="c"> * @param oArgs.event {HTMLEvent} Event object.</span>
<span class="c"> * @param oArgs.target {HTMLElement} Target element.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">onEventFormatCell</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">oArgs</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">evt</span> <span class="o">=</span> <span class="nx">oArgs</span><span class="o">.</span><span class="nx">event</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">element</span> <span class="o">=</span> <span class="nx">oArgs</span><span class="o">.</span><span class="nx">target</span><span class="o">;</span>

    <span class="c">//TODO: add a safety net in case TD is never reached</span>
<span class="c"></span>    <span class="c">// Walk up the DOM until we get to the TD</span>
<span class="c"></span>    <span class="k">while</span><span class="o">(</span><span class="nx">element</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">()</span> <span class="o">!=</span> <span class="s2">&quot;td&quot;</span><span class="o">)</span> <span class="o">{</span>
        <span class="nx">element</span> <span class="o">=</span> <span class="nx">element</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">;</span>
    <span class="o">}</span>

    <span class="k">this</span><span class="o">.</span><span class="nx">formatCell</span><span class="o">(</span><span class="nx">element</span><span class="o">);</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Overridable custom event handler to highlight cell.</span>
<span class="c"> *</span>
<span class="c"> * @method onEventHighlightCell</span>
<span class="c"> * @param oArgs.event {HTMLEvent} Event object.</span>
<span class="c"> * @param oArgs.target {HTMLElement} Target element.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">onEventHighlightCell</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">oArgs</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">evt</span> <span class="o">=</span> <span class="nx">oArgs</span><span class="o">.</span><span class="nx">event</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">element</span> <span class="o">=</span> <span class="nx">oArgs</span><span class="o">.</span><span class="nx">target</span><span class="o">;</span>

    <span class="c">//TODO: add a safety net in case TD is never reached</span>
<span class="c"></span>    <span class="c">// Walk up the DOM until we get to the TD</span>
<span class="c"></span>    <span class="k">while</span><span class="o">(</span><span class="nx">element</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">()</span> <span class="o">!=</span> <span class="s2">&quot;td&quot;</span><span class="o">)</span> <span class="o">{</span>
        <span class="nx">element</span> <span class="o">=</span> <span class="nx">element</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">;</span>
    <span class="o">}</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">highlight</span><span class="o">(</span><span class="nx">element</span><span class="o">);</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Overridable custom event handler to unhighlight cell.</span>
<span class="c"> *</span>
<span class="c"> * @method onEventUnhighlightCell</span>
<span class="c"> * @param oArgs.event {HTMLEvent} Event object.</span>
<span class="c"> * @param oArgs.target {HTMLElement} Target element.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">onEventUnhighlightCell</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">oArgs</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">evt</span> <span class="o">=</span> <span class="nx">oArgs</span><span class="o">.</span><span class="nx">event</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">element</span> <span class="o">=</span> <span class="nx">oArgs</span><span class="o">.</span><span class="nx">target</span><span class="o">;</span>

    <span class="c">//TODO: add a safety net in case TD is never reached</span>
<span class="c"></span>    <span class="c">// Walk up the DOM until we get to the TD</span>
<span class="c"></span>    <span class="k">while</span><span class="o">(</span><span class="nx">element</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">()</span> <span class="o">!=</span> <span class="s2">&quot;td&quot;</span><span class="o">)</span> <span class="o">{</span>
        <span class="nx">element</span> <span class="o">=</span> <span class="nx">element</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">;</span>
    <span class="o">}</span>
    
    <span class="k">this</span><span class="o">.</span><span class="nx">unhighlight</span><span class="o">(</span><span class="nx">element</span><span class="o">);</span>
<span class="o">};</span>
<span class="c">/**</span>
<span class="c"> * Overridable custom event handler to edit cell.</span>
<span class="c"> *</span>
<span class="c"> * @method onEventEditCell</span>
<span class="c"> * @param oArgs.event {HTMLEvent} Event object.</span>
<span class="c"> * @param oArgs.target {HTMLElement} Target element.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">onEventEditCell</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">oArgs</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">var</span> <span class="nx">evt</span> <span class="o">=</span> <span class="nx">oArgs</span><span class="o">.</span><span class="nx">event</span><span class="o">;</span>
    <span class="k">var</span> <span class="nx">element</span> <span class="o">=</span> <span class="nx">oArgs</span><span class="o">.</span><span class="nx">target</span><span class="o">;</span>

    <span class="c">//TODO: add a safety net in case TD is never reached</span>
<span class="c"></span>    <span class="c">// Walk up the DOM until we get to the TD</span>
<span class="c"></span>    <span class="k">while</span><span class="o">(</span><span class="nx">element</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">()</span> <span class="o">!=</span> <span class="s2">&quot;td&quot;</span><span class="o">)</span> <span class="o">{</span>
        <span class="nx">element</span> <span class="o">=</span> <span class="nx">element</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">;</span>
    <span class="o">}</span>

    <span class="k">this</span><span class="o">.</span><span class="nx">editCell</span><span class="o">(</span><span class="nx">element</span><span class="o">);</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Handles data return for adding new rows to table, including updating pagination.</span>
<span class="c"> *</span>
<span class="c"> * @method onDataReturnPaginateRows</span>
<span class="c"> * @param sRequest {String} Original request.</span>
<span class="c"> * @param oResponse {Object} Response object.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">onDataReturnPaginateRows</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">sRequest</span><span class="o">,</span> <span class="nx">oResponse</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;dataReturnEvent&quot;</span><span class="o">,</span> <span class="o">{</span><span class="nx">request</span><span class="o">:</span><span class="nx">sRequest</span><span class="o">,</span><span class="nx">response</span><span class="o">:</span><span class="nx">oResponse</span><span class="o">});</span>
    
    <span class="k">var</span> <span class="nx">ok</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">doBeforeLoadData</span><span class="o">(</span><span class="nx">sRequest</span><span class="o">,</span> <span class="nx">oResponse</span><span class="o">);</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">ok</span><span class="o">)</span> <span class="o">{</span>
        <span class="c">// Update the RecordSet from the response</span>
<span class="c"></span>        <span class="k">var</span> <span class="nx">newRecords</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oRecordSet</span><span class="o">.</span><span class="nx">append</span><span class="o">(</span><span class="nx">oResponse</span><span class="o">);</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">newRecords</span><span class="o">)</span> <span class="o">{</span>
            <span class="c">// Update markup</span>
<span class="c"></span>            <span class="k">this</span><span class="o">.</span><span class="nx">paginateRows</span><span class="o">();</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Data returned for &quot;</span> <span class="o">+</span> <span class="nx">newRecords</span><span class="o">.</span><span class="nx">length</span> <span class="o">+</span> <span class="s2">&quot; rows&quot;</span><span class="o">,</span><span class="s2">&quot;info&quot;</span><span class="o">,</span><span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
        <span class="o">}</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Handles data return for adding new rows to bottom of table.</span>
<span class="c"> *</span>
<span class="c"> * @method onDataReturnAppendRows</span>
<span class="c"> * @param sRequest {String} Original request.</span>
<span class="c"> * @param oResponse {Object} Response object.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">onDataReturnAppendRows</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">sRequest</span><span class="o">,</span> <span class="nx">oResponse</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;dataReturnEvent&quot;</span><span class="o">,</span> <span class="o">{</span><span class="nx">request</span><span class="o">:</span><span class="nx">sRequest</span><span class="o">,</span><span class="nx">response</span><span class="o">:</span><span class="nx">oResponse</span><span class="o">});</span>
    
    <span class="k">var</span> <span class="nx">ok</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">doBeforeLoadData</span><span class="o">(</span><span class="nx">sRequest</span><span class="o">,</span> <span class="nx">oResponse</span><span class="o">);</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">ok</span><span class="o">)</span> <span class="o">{</span>
        <span class="c">// Update the RecordSet from the response</span>
<span class="c"></span>        <span class="k">var</span> <span class="nx">newRecords</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oRecordSet</span><span class="o">.</span><span class="nx">append</span><span class="o">(</span><span class="nx">oResponse</span><span class="o">);</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">newRecords</span><span class="o">)</span> <span class="o">{</span>
            <span class="c">// Update markup</span>
<span class="c"></span>            <span class="k">this</span><span class="o">.</span><span class="nx">appendRows</span><span class="o">(</span><span class="nx">newRecords</span><span class="o">);</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Data returned for &quot;</span> <span class="o">+</span> <span class="nx">newRecords</span><span class="o">.</span><span class="nx">length</span> <span class="o">+</span> <span class="s2">&quot; rows&quot;</span><span class="o">,</span><span class="s2">&quot;info&quot;</span><span class="o">,</span><span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
        <span class="o">}</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Handles data return for inserting new rows to top of table.</span>
<span class="c"> *</span>
<span class="c"> * @method onDataReturnInsertRows</span>
<span class="c"> * @param sRequest {String} Original request.</span>
<span class="c"> * @param oResponse {Object} Response object.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">onDataReturnInsertRows</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">sRequest</span><span class="o">,</span> <span class="nx">oResponse</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;dataReturnEvent&quot;</span><span class="o">,</span> <span class="o">{</span><span class="nx">request</span><span class="o">:</span><span class="nx">sRequest</span><span class="o">,</span><span class="nx">response</span><span class="o">:</span><span class="nx">oResponse</span><span class="o">});</span>
    
    <span class="k">var</span> <span class="nx">ok</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">doBeforeLoadData</span><span class="o">(</span><span class="nx">sRequest</span><span class="o">,</span> <span class="nx">oResponse</span><span class="o">);</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">ok</span><span class="o">)</span> <span class="o">{</span>
        <span class="c">// Update the RecordSet from the response</span>
<span class="c"></span>        <span class="k">var</span> <span class="nx">newRecords</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oRecordSet</span><span class="o">.</span><span class="nx">insert</span><span class="o">(</span><span class="nx">oResponse</span><span class="o">);</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">newRecords</span><span class="o">)</span> <span class="o">{</span>
            <span class="c">// Update markup</span>
<span class="c"></span>            <span class="k">this</span><span class="o">.</span><span class="nx">insertRows</span><span class="o">(</span><span class="nx">newRecords</span><span class="o">);</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Data returned for &quot;</span> <span class="o">+</span> <span class="nx">newRecords</span><span class="o">.</span><span class="nx">length</span> <span class="o">+</span> <span class="s2">&quot; rows&quot;</span><span class="o">,</span><span class="s2">&quot;info&quot;</span><span class="o">,</span><span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
        <span class="o">}</span>
    <span class="o">}</span>
<span class="o">};</span>

<span class="c">/**</span>
<span class="c"> * Handles data return for replacing all existing of table with new rows.</span>
<span class="c"> *</span>
<span class="c"> * @method onDataReturnReplaceRows</span>
<span class="c"> * @param sRequest {String} Original request.</span>
<span class="c"> * @param oResponse {Object} Response object.</span>
<span class="c"> */</span>
<span class="nx">YAHOO</span><span class="o">.</span><span class="nx">widget</span><span class="o">.</span><span class="nx">DataTable</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">onDataReturnReplaceRows</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">sRequest</span><span class="o">,</span> <span class="nx">oResponse</span><span class="o">)</span> <span class="o">{</span>
    <span class="k">this</span><span class="o">.</span><span class="nx">fireEvent</span><span class="o">(</span><span class="s2">&quot;dataReturnEvent&quot;</span><span class="o">,</span> <span class="o">{</span><span class="nx">request</span><span class="o">:</span><span class="nx">sRequest</span><span class="o">,</span><span class="nx">response</span><span class="o">:</span><span class="nx">oResponse</span><span class="o">});</span>
    
    <span class="k">var</span> <span class="nx">ok</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">doBeforeLoadData</span><span class="o">(</span><span class="nx">sRequest</span><span class="o">,</span> <span class="nx">oResponse</span><span class="o">);</span>
    <span class="k">if</span><span class="o">(</span><span class="nx">ok</span><span class="o">)</span> <span class="o">{</span>
        <span class="c">// Update the RecordSet from the response</span>
<span class="c"></span>        <span class="k">var</span> <span class="nx">newRecords</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_oRecordSet</span><span class="o">.</span><span class="nx">replace</span><span class="o">(</span><span class="nx">oResponse</span><span class="o">);</span>
        <span class="k">if</span><span class="o">(</span><span class="nx">newRecords</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">this</span><span class="o">.</span><span class="nx">replaceRows</span><span class="o">(</span><span class="nx">newRecords</span><span class="o">);</span>
            <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s2">&quot;Data returned for &quot;</span> <span class="o">+</span> <span class="nx">newRecords</span><span class="o">.</span><span class="nx">length</span> <span class="o">+</span> <span class="s2">&quot; rows&quot;</span><span class="o">,</span><span class="s2">&quot;info&quot;</span><span class="o">,</span><span class="k">this</span><span class="o">.</span><span class="nx">toString</span><span class="o">());</span>
        <span class="o">}</span>
    <span class="o">}</span>
<span class="o">};</span>
</pre></div>
                    </div>
			</div>
		</div>
		<div class="yui-b">
            <div class="nav">

                    <div class="module">
                        <h4>Modules</h4>
                        <ul class="content">

                                <li class=""><a href="module_animation.html">animation</a></li>

                                <li class=""><a href="module_autocomplete.html">autocomplete</a></li>

                                <li class=""><a href="module_button.html">button</a></li>

                                <li class=""><a href="module_calendar.html">calendar</a></li>

                                <li class=""><a href="module_connection.html">connection</a></li>

                                <li class=""><a href="module_container.html">container</a></li>

                                <li class=""><a href="module_datasource.html">datasource</a></li>

                                <li class="selected"><a href="module_datatable.html">datatable</a></li>

                                <li class=""><a href="module_dom.html">dom</a></li>

                                <li class=""><a href="module_dragdrop.html">dragdrop</a></li>

                                <li class=""><a href="module_element.html">element</a></li>

                                <li class=""><a href="module_event.html">event</a></li>

                                <li class=""><a href="module_history.html">history</a></li>

                                <li class=""><a href="module_logger.html">logger</a></li>

                                <li class=""><a href="module_menu.html">menu</a></li>

                                <li class=""><a href="module_slider.html">slider</a></li>

                                <li class=""><a href="module_tabview.html">tabview</a></li>

                                <li class=""><a href="module_treeview.html">treeview</a></li>

                                <li class=""><a href="module_yahoo.html">yahoo</a></li>
                        </ul>
                    </div>

                    <div class="module">
                        <h4>Classes</h4>
                        <ul class="content">
                                <li class=""><a href="Column.html">Column</a></li>
                                <li class=""><a href="ColumnEditor.html">ColumnEditor</a></li>
                                <li class=""><a href="ColumnSet.html">ColumnSet</a></li>
                                <li class=""><a href="DataTable.html">DataTable</a></li>
                                <li class=""><a href="Record.html">Record</a></li>
                                <li class=""><a href="RecordSet.html">RecordSet</a></li>
                                <li class=""><a href="Sort.html">Sort</a></li>
                                <li class=""><a href="WidthResizer.html">WidthResizer</a></li>
                        </ul>
                    </div>

                    <div class="module">
                        <h4>Files</h4>
                        <ul class="content">        
                                <li class=""><a href="ColumnSet.js.html">ColumnSet.js</a></li>
                                <li class="selected"><a href="DataTable.js.html">DataTable.js</a></li>
                                <li class=""><a href="RecordSet.js.html">RecordSet.js</a></li>
                        </ul>
                    </div>





            </div>
		</div>
	</div>
	<div id="ft">
        <hr />
        Copyright &copy; 2007 Yahoo! Inc. All rights reserved.
	</div>
</div>
</body>
</html>
